I try to develop school bell application using NAudio with timer. I compare the timer with data stored in database. Here the code ( I take code from the example from NAudio):
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = TimeOfDay bellEnabled = True For Each r As DataGridViewRow In DataGridView1.Rows Dim jam As String = Convert.ToString(r.Cells) If r.Cells("jm").Value = Label2.Text And bellEnabled = True Then 'taken from datagridview Dim nmFile As String nmFile = "E:\bell1.mp3" waveOutDevice = New WaveOut(callbackInfo) mainOutputStream = CreateInputStream(nmFile) waveOutDevice.Init(mainOutputStream) waveOutDevice.Play() End If Next End Sub
This code didn't work fine. The output sound is 'broken' (sorry for my bad English). But when I set 'bellEnabled' and 'timer1.Enabled' to false the output sound was perfect. How solve this..? I need the timer to run continuously and compare it with database...
Thanks for help