Hi Everyone,
Please look at my coding. I have 2 media players set up but they are not working as expected. Initially I have a select statement set that catches when the time is 5 and 10 minutes past the hour and also on the hour. On the hour, I'm trying to get one media player to play a sound file and have the other player play another sound file only when the first one has finished playing it's sound file. This problem does not occur when only the 5 and 10 minute sound files are play since no other sound file is played afterwards.
On the hour one sound file gets played and when the code reaches the play statement on the other media player the first media player repeats the sound file that was loaded into it then the second media player plays it's sound file.
The problem occurs when this statement is executed:
As you can see, there is no other code that plays the first sound file.
What am I doing wrong?
Here's the coding:
Please look at my coding. I have 2 media players set up but they are not working as expected. Initially I have a select statement set that catches when the time is 5 and 10 minutes past the hour and also on the hour. On the hour, I'm trying to get one media player to play a sound file and have the other player play another sound file only when the first one has finished playing it's sound file. This problem does not occur when only the 5 and 10 minute sound files are play since no other sound file is played afterwards.
On the hour one sound file gets played and when the code reaches the play statement on the other media player the first media player repeats the sound file that was loaded into it then the second media player plays it's sound file.
The problem occurs when this statement is executed:
B4X:
mpHourlyMediaPlayer.Play
As you can see, there is no other code that plays the first sound file.
What am I doing wrong?
Here's the coding:
B4X:
Sub Service_Create
ToastMessageShow( "Sounds Enabled",False)
blnOkToSound = True
' Set up the media players.
'--------------------------
mpMinutesMediaPlayer.Initialize2("MinutesMediaPlayer")
mpHourlyMediaPlayer.Initialize
' Start the timer.
'-----------------
tmrTimer.Initialize("EventTimer", 1000)
tmrTimer.Enabled = True
End Sub
B4X:
Sub EventTimer_Tick
lngTheTimeNow = DateTime.Now
intHours = DateTime.GetHour(lngTheTimeNow)
intMinutes = DateTime.GetMinute(lngTheTimeNow)
intSeconds = DateTime.GetSecond(lngTheTimeNow)
Select intMinutes
Case 5
If mpMinutesMediaPlayer.IsPlaying = False _
And intSeconds = 0 Then
mpMinutesMediaPlayer.Load(File.DirAssets,"5Minutes.mp3")
mpMinutesMediaPlayer.Play
End If
Case 10
If mpMinutesMediaPlayer.IsPlaying = False _
And intSeconds = 0 Then
mpMinutesMediaPlayer.Load(File.DirAssets,"10Minutes.mp3")
mpMinutesMediaPlayer.Play
End If
Case 0
If mpMinutesMediaPlayer.IsPlaying = False _
And intSeconds = 0 Then
mpMinutesMediaPlayer.Load(File.DirAssets,"hourly.mp3")
mpMinutesMediaPlayer.Play
blnOnTheHour = True
End If
End Select ' intMinutes
End Sub
B4X:
Sub MinutesMediaPlayer_Complete
If blnOnTheHour = True Then
PlayHourlySounds
blnOnTheHour = False
End If
B4X:
Sub PlayHourlySounds
Select intHours
Case 1, 13
If mpHourlyMediaPlayer.IsPlaying = False Then
mpHourlyMediaPlayer.Load(File.DirAssets, "1oclock.mp3")
mpHourlyMediaPlayer.Play
End If
Case 2, 14
If mpHourlyMediaPlayer.IsPlaying = False Then
mpHourlyMediaPlayer.Load(File.DirAssets, "2oclock.mp3")
mpHourlyMediaPlayer.Play
End If
End Select