Android Question MediaPlayer - delay between repetative MP.play

Declan

Well-Known Member
Licensed User
Longtime User
I have a mp3 audio file that I play to alert the user of an alarm event.
The duration of the mp3 file is 15 seconds.
I have 3 settings for the "alarm duration" 15 seconds, 30 seconds and continuous.
The 15 seconds setting plays the mp3 once.
The 30 seconds setting plays the mp3 twice.
The Continuous setting plays the mp3 max 6 times.

I am attempting to create a "delay" between the playing of the mp3 for the 30 seconds and Continuous.

I tried the following, but the "delay" is very short and not the 10 second delay.
B4X:
    If (alarmState = "15") Then
        MP.load(File.DirAssets, "alarm-15.mp3")
        MP.Looping = False
        MP.play
    End If
   
    If (alarmState = "30") Then
        MP.load(File.DirAssets, "alarm-15.mp3")
        MP.Looping = False
        MP.play
        Sleep(10000)
        MP.load(File.DirAssets, "alarm-15.mp3")
        MP.Looping = False
        MP.play
    End If

The above code does not accommodate the Continuous setting.
 
Top