Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private storage As ExternalStorage
Private player As SimpleExoPlayer
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
storage.Initialize(Me, "storage")
player.Initialize("exoplayer")
End Sub
Sub Button1_Click
storage.SelectDir(True)
Wait For Storage_ExternalFolderAvailable
Dim music As ExternalFile = storage.FindFile(storage.Root, "2.mp3")
If music.IsInitialized Then
Dim uri As String = music.Native.RunMethodJO("getUri", Null).RunMethod("toString", Null)
Log(uri)
player.Prepare(player.CreateUriSource(uri))
End If
End Sub
Sub ExoPlayer_Ready
Log("ready")
player.Play
End Sub
Sub ExoPlayer_Error (Message As String)
Log("error: " & Message)
End Sub