|
-
Jun 2nd, 2026, 12:37 AM
#1
Thread Starter
New Member
Can't hear WAVE file. No sound, no errors.
Hi,
I'm sure this has been done to death but I need some help to play a WAVE file.
I'm using Windows 11 and VB.NET 2026.
Code:
Try
'My.Computer.Audio.Play("e:\MyStuff\TestTone.wav", AudioPlayMode.WaitToComplete)
My.Computer.Audio.Play(A, AudioPlayMode.WaitToComplete)
Catch ex As Exception
Stop
End Try
If tried both a file and a byte array, no luck.
Any ideas?
-
Jun 2nd, 2026, 05:09 AM
#2
Thread Starter
New Member
Re: Can't hear WAVE file. No sound, no errors.
Perhaps a bit more information.
Decades ago I used a database called Clipper and it had a neat function that played a specified pitch for a specified duration.
I wanted that ability in VB.NET.
I created a function that creates a WAV file with a specified pitch and duration. PlayPitch(440, 1)
Everything works except the play function.
If I use Windows Explorer I can click on the file and I can hear the sound.
Weird huh?
-
Jun 2nd, 2026, 06:36 AM
#3
Thread Starter
New Member
Re: Can't hear WAVE file. No sound, no errors.
Hi Folks,
A little sheepish here, I found the problem. I had a parameter wrong in the format chunk.
After a great deal of detective work I found the issue.
IT WORKS!
I'm still confused as the original file played in the media player but not VB.NET
-
Jun 2nd, 2026, 12:27 PM
#4
Re: Can't hear WAVE file. No sound, no errors.
VB.Net wave players are temperamental, but the rule is they must be PCM wav files. I’m not sure what caused your file not working though…
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Re: Can't hear WAVE file. No sound, no errors.
Just as a matter of curiosity, how are you creating the wav file? Do you mind sharing?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Re: Can't hear WAVE file. No sound, no errors.
If possible, you should avoid using the `My` namespace in VB.NET. This namespace does not exist in C#, which means your code would not be convertible to C#. It would be better to use the `System.Media` namespace instead of `My.Computer.Audio`. Alternatively, you also have the option of using Media Foundation for playback.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|