Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private SimpleExoPlayerView1 As SimpleExoPlayerView
Private player1 As SimpleExoPlayer
Private const MAXCH=6 As Int
Private url(MAXCH) As String
Private ch As Int=0
Private Panel1 As B4XView
Private phoneVol As Phone
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
url(0) = "http://playtv-live.test.com/live/1.m3u8"
url(1) = "http://playtv-live.test.com/live/2.m3u8"
.
url(n) = ...
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
player1.Initialize("player")
SimpleExoPlayerView1.ResizeMode="FILL"
Tv_play(url(ch)) 'Firtst play it works well
End Sub
Private Sub Tv_play(s As String)
'player1.Prepare(player1.CreateHLSSource(s))
'SimpleExoPlayerView1.Player = player1
'player1.Play
Dim sources As List
sources.Initialize
sources.Add(player1.CreateHLSSource(s))
player1.Prepare(player1.CreateListSource(sources))
SimpleExoPlayerView1.Player = player1
player1.Play
End Sub
'pseudo code'
Keypress event()
case Down
ch = ch + 1
case Up
ch = ch -1
call Tv_play(url(ch)) 'After change channel , errormsg is thrown out