|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Playing sounds from resources in VB2005Using 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.GoOnline, AudioPlayMode.Background) Case 2 : My.Computer.Audio.Play(My.Resources.Sounds.DoorOpen, AudioPlayMode.Background) Case 3 : My.Computer.Audio.Play(My.Resources.Sounds.DoorSlam, AudioPlayMode.Background) Case 4 : My.Computer.Audio.Play(My.Resources.Sounds.PrivateMsg, 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? 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 Show quoteHide quote "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.GoOnline, > AudioPlayMode.Background) > Case 2 : My.Computer.Audio.Play(My.Resources.Sounds.DoorOpen, > AudioPlayMode.Background) > Case 3 : My.Computer.Audio.Play(My.Resources.Sounds.DoorSlam, > AudioPlayMode.Background) > Case 4 : My.Computer.Audio.Play(My.Resources.Sounds.PrivateMsg, > 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? > > >
User's Mail Editor
Problème data tramsmission from tableadapter to ACCESS database Odd or Even How to: Retrieving BuiltinDocumentProperties from Word Document How to: Omit Deafulted Elements from XML When Serializing late binding problem with option strict What happen to Find in Files in VS2005? Hpow to create a background process/application? convert rtf to html Can't get a value from my app.config file |
|||||||||||||||||||||||