Sound with VB6

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2008
Posts: 6
Reputation: Mikecc2691 is an unknown quantity at this point 
Solved Threads: 0
Mikecc2691 Mikecc2691 is offline Offline
Newbie Poster

Sound with VB6

 
0
  #1
Mar 10th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,144
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 132
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Sound with VB6

 
0
  #2
Mar 11th, 2008
try using the API PlaySound.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 6
Reputation: Mikecc2691 is an unknown quantity at this point 
Solved Threads: 0
Mikecc2691 Mikecc2691 is offline Offline
Newbie Poster

Re: Sound with VB6

 
0
  #3
Mar 11th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Sound with VB6

 
0
  #4
Mar 11th, 2008
  1. Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
  2.  
  3. Const SND_ASYNC = &H1
  4. Const SND_LOOP = &H8
  5. Const SND_MEMORY = &H4
  6. Const SND_NODEFAULT = &H2
  7. Const SND_NOSTOP = &H10
  8. Const SND_SYNC = &H0
  9.  
  10. Private Sub cmdPlay_Click()
  11. Dim Result As Long
  12. Dim SoundFile As String
  13.  
  14. ' set file name
  15. SoundFile = "C:\DÖNALd.wav"
  16.  
  17. ' Play wave file
  18. Result = sndPlaySound(SoundFile, SND_ASYNC)
  19.  
  20. End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 6
Reputation: Mikecc2691 is an unknown quantity at this point 
Solved Threads: 0
Mikecc2691 Mikecc2691 is offline Offline
Newbie Poster

Re: Sound with VB6

 
0
  #5
Mar 12th, 2008
Hi. Many thanks for this code. I am still learning VB, so pointing me in the right direction like this is a real help. Mikecc2691.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Sound with VB6

 
2
  #6
Mar 12th, 2008
you're welcome. don't forget to mark this thread solved.
happy coding friend
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 1377 | Replies: 5
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC