Media End Event in Media Player

junaidahmed

Well-Known Member
Licensed User
Longtime User
How to use MediaEnd event for Media Player in Basic4Android,so that i can play all mp3 files automatically.pls advise
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Something like:
B4X:
Sub Process_Globals
    Dim mp As MediaPlayer
    Dim Timer1 As Timer
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        mp.Initialize
        Timer1.Initialize("Timer1", 0)
    End If
    
End Sub
Sub PlaySong(song As String)
    mp.Load(File.DirRootExternal, song)
    Timer1.Interval = mp.Duration + 100
    mp.Play
    Timer1.Enabled = True
End Sub
Sub Timer1_Tick
    Timer1.Enabled = False
    PlaySong("nextsong")
End Sub
 
Upvote 0
Top