RishiKumar2210
Active Member
Hi. I want to Play the Alarm Sound after some time(multiple times) from the current time. Here I am using the Flexgrid table to store when the alarm needs to play. Suppose I have 2 rows(the first row is 10 seconds and 2nd row is 15 seconds). I want to play an alarm sound after 10 seconds from the current time and then play an alarm sound again after 15 seconds from the first alarm sound. But My code plays the Alarm sound Only 1 time. what's wrong with this code?Here is my code
B4X:
Private Sub btn_startalarm_Click
timer1.Enabled = True
For i = 0 To if_flexgridtabledetailslist.RowCount - 1
Dim rowdata As List = if_flexgridtabledetailslist.GetCellRow(i)
Dim ls_time As String = rowdata.Get(1)
Dim ls_minsec As String = rowdata.Get(2)
Log(ls_time)
Dim ls_totaltime As String = ls_time & " " & ls_minsec
Log("totaltime : " & ls_totaltime)
Dim p As Period
If ls_minsec == "Minutes" Then
p.Minutes = ls_time
Else If ls_minsec == "Seconds" Then
p.Seconds = ls_time
End If
is_currenttime = DateTime.Now
is_nexttime = DateUtils.AddPeriod(DateTime.Now, p)
Log("currenttime : " & DateTime.Time(is_currenttime))
Log("nexttime : " & DateTime.Time(is_nexttime))
Sleep(is_nexttime)
Timer1_Tick
Next
End Sub
Sub Timer1_Tick
' Check if the current time has reached or passed the next time
If DateTime.Now >= is_nexttime Then
timer1.Enabled = False ' Disable the timer
' MsgboxAsync("Success", "Time Alert")
imedia_player.Load(File.DirAssets, "beepsound.mp3")
imedia_player.Play
End If
End Sub