| | |
Sound with VB6
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2008
Posts: 6
Reputation:
Solved Threads: 0
Hi. I am new to DaniWeb so I hope I am doing this right. I am an amateur VB programmer. I wrote a VB6 program that featured a fruit machine with changing letters in the windows. To add sound I used the code line (e.g.) MediaPlayer5.Play. My recollection is that I set up all the parameters for the MediaPlayer object in the properties window for the appropriate Media Player object at design time. This would have included the relevant sound file. It all worked beautifully, and I also used the same technique for playing a video clip. At the time I had Media Player 9 on my PC. Now I have returned to working on the program and VB 6 appears not to recognise the method. I now have Media Player 10 on my PC, but I have also tried my existing program after rolling back to Media Player 9, and it still does not work. All the code is the original code that worked fine. What has changed ? It was such a simple method to use. Thanks if you can help. Mikecc2691.
•
•
Join Date: Mar 2008
Posts: 6
Reputation:
Solved Threads: 0
Hi. Many thanks for that suggestion. I haven't used APIs yet - this will be a useful way of getting to know about them. I would still like to know what has changed since I wrote my original code. There is no doubt that it worked, over a long period of development now it doesn't - so something must have changed. VB tells me it does not recognise the method. And the strange thing is that no publication seems to mention the method MediaPlayer1. Play. I suspect it is Media Player itself that has changed, as I can no longer see a suitable place in the properties box to enter the file I wish to play. Anyway, your suggestion has the advantage of forcing me to learn about APIs which will clearly be useful beyond the immediate program. Regards. Mike.
vb Syntax (Toggle Plain Text)
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Const SND_ASYNC = &H1 Const SND_LOOP = &H8 Const SND_MEMORY = &H4 Const SND_NODEFAULT = &H2 Const SND_NOSTOP = &H10 Const SND_SYNC = &H0 Private Sub cmdPlay_Click() Dim Result As Long Dim SoundFile As String ' set file name SoundFile = "C:\DÖNALd.wav" ' Play wave file Result = sndPlaySound(SoundFile, SND_ASYNC) End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
you're welcome. don't forget to mark this thread solved. 
happy coding friend

happy coding friend
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
![]() |
Similar Threads
- vb6 newbie needing some help (Visual Basic 4 / 5 / 6)
- how to insert sound in vb6 programming (Visual Basic 4 / 5 / 6)
- making a stream server code (VB6) (Visual Basic 4 / 5 / 6)
- Shoutcast metada (VB6) (Visual Basic 4 / 5 / 6)
- .NET vs VB6 - differences? (VB.NET)
- Sound manuplating in vb 6 (Visual Basic 4 / 5 / 6)
- tranmit sound (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Strange Source Safe issue
- Next Thread: question
Views: 1377 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






