• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

VB Playing WAV Files

I have the following declaration on a module.
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

I have the following call on a form.  Card.wav is in the same directory as the executable.
PlaySound("card.wav", 0, 0)

On my machine, and on other non-development machines, I can here the wav file fine.  But on a few machines, I am unable to hear it.  Is there another way to play a wav file, or does anyone have a solution to this.  The wav file will play fine in Windows Media Player outside of the VB program.

Thanks



0
Fraser_Admin
Asked:
Fraser_Admin
  • 8
  • 4
  • 2
  • +2
1 Solution
 
Harisha M GCommented:
Hi Fraser_Admin,
    Try...
Private Declare Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName _
As String, ByVal uFlags As Long) As Long

Bye
---
Harish
0
 
Harisha M GCommented:
Fraser_Admin,
sndPlaySound32("Card.wav", 1)
0
 
Fraser_AdminAuthor Commented:
I tried this first.  It works fine on some machines.  So I'm guessing I'm missing a dll or something.  No clue???
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Harisha M GCommented:
If missing, it should be "winmm.dll".. but since you have media player, generally it will be present.

Look at C:\Windows\System32
0
 
gecko_au2003Commented:
A full coded example :

http://www.expressnewsindia.com/c4/ex2/C1193.html

A good example on how to use that function along with all the constants , etc that you can use :

http://rookscape.com/vbgaming/tutB.php

Other then that I will keep myself subcribed to this question to see how it goes :) As I dont want to keep spamming this question !
0
 
TDSnetCommented:
Probably stating the obvious here but have you tested the sound on these machines manually..?
0
 
Fraser_AdminAuthor Commented:
Yes, the wav file plays fine when you play it outside of code on the affected machines.  I don't think it is a problem with my code since it works fine on my development machine and also works on some production machines.  Yes winmm.dll is in c:\winnt\system32 on both the machines that work and those that do not.
0
 
Fraser_AdminAuthor Commented:
Also I am playing it with this flag: &H1
0
 
gecko_au2003Commented:
When you say it does not work on those machines that have the winmm.dll, does it give you any errors ? Also are the latest visual basic 6 runtime files on all of the machines or any other files or dependancies for that matter ? Are all the files  that need to be registered are registered using regsvr32 ??

Just some thoughts that you could try out, is all :)
0
 
Fraser_AdminAuthor Commented:
As far as I know everything is fine.  No errors, it just doesn't play.  What files should I be looking for for vb runtime files?
0
 
Fraser_AdminAuthor Commented:
I will check out this and let you know if it makes a difference.
0
 
Fraser_AdminAuthor Commented:
That did not help.
0
 
Fraser_AdminAuthor Commented:
It is very strange.  We have found some wav files will play and some will not.  No clue what the problem could be.
0
 
Fraser_AdminAuthor Commented:
Although my problem is not fixed, I will award mgh_mgharish the points since you had several suggestions.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 8
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now