By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,292 Members | 1,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,292 IT Pros & Developers. It's quick & easy.

Playing sounds from resources in VB2005

P: n/a
Using the following routine to play embedded wav files:

Private Sub PlaySound(ByVal Sound As Int32)
Select Case Sound
Case 1 : My.Computer.Audio.Play(My.Resources.Sounds.GoOnlin e,
AudioPlayMode.Background)
Case 2 : My.Computer.Audio.Play(My.Resources.Sounds.DoorOpe n,
AudioPlayMode.Background)
Case 3 : My.Computer.Audio.Play(My.Resources.Sounds.DoorSla m,
AudioPlayMode.Background)
Case 4 : My.Computer.Audio.Play(My.Resources.Sounds.Private Msg,
AudioPlayMode.Background)
End Select
End Sub

Occasionally, instead of hearing the sound, i just hear white noise. This
doesn't happen if I play the sounds from files. Is there a better way to
play sound resources to eliminate the white noise anamoly?
Jan 28 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Max
Hi

I had this problem too. Finally I solved this by performing this playing the
sound synchronosly in a backgroundworkerprocess.
Private WithEvents bkw As New System.ComponentModel.BackgroundWorker
Public Sub PlaySound(ByVal Sound As System.IO.UnmanagedMemoryStream)
If bkw.IsBusy Then Exit Sub
bkw.RunWorkerAsync(Sound)
End Sub

Private Sub bkw_DoWork(ByVal sender As Object, ByVal e As
System.ComponentModel.DoWorkEventArgs) Handles bkw.DoWork
My.Computer.Audio.Play(e.Argument, AudioPlayMode.WaitToComplete)
End Sub

"Terry Olsen" wrote:
Using the following routine to play embedded wav files:

Private Sub PlaySound(ByVal Sound As Int32)
Select Case Sound
Case 1 : My.Computer.Audio.Play(My.Resources.Sounds.GoOnlin e,
AudioPlayMode.Background)
Case 2 : My.Computer.Audio.Play(My.Resources.Sounds.DoorOpe n,
AudioPlayMode.Background)
Case 3 : My.Computer.Audio.Play(My.Resources.Sounds.DoorSla m,
AudioPlayMode.Background)
Case 4 : My.Computer.Audio.Play(My.Resources.Sounds.Private Msg,
AudioPlayMode.Background)
End Select
End Sub

Occasionally, instead of hearing the sound, i just hear white noise. This
doesn't happen if I play the sounds from files. Is there a better way to
play sound resources to eliminate the white noise anamoly?

Mar 17 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.