Hi all o7.
Consider a timer to perform
A 500ms timer and 1000ms audio file will lead to cutting audio file and startover. I've tried threading but in a bad way, causing the UI freezing while it finishes the work.Code:My.Computer.Audio.Play(My.Resources.Test, AudioPlayMode.Background)
Since twice of the duration is enough for audio length, Is it possible to toggle a boolean variable to perform each players/threads in a see-saw way?
Should I double the Media.SoundPlayer?
Or should I double the threads? Or should I do both???Code:Private Sub PlaySound1() Dim soundPlayer As New Media.SoundPlayer(My.Resources.test) soundPlayer.PlaySync() End Sub Private Sub PlaySound2() Dim soundPlayer As New Media.SoundPlayer(My.Resources.test) soundPlayer.PlaySync() End Sub
Does Media.SoundPlayer even able to perform a sort of buffered "layering" of waves? Also simple form of "SoundPlayer.Play()" acts like first example.Code:Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick If ToggleSound Then SoundThread1 = New Thread(AddressOf PlaySound1) SoundThread1.Start() Else SoundThread2 = New Thread(AddressOf PlaySound2) SoundThread2.Start() End If ToggleSound = Not ToggleSound End Sub
Current results with 250ms timer for test: They keep playing slowly to finish entire file ignorantly, closing the form will not stop them (Depends on how long you spend x250ms while form was open, then stop runtime).




Reply With Quote
