Android Question Exoplayer is failed to switch HLSsource on Android TV

teddybear

Well-Known Member
Licensed User
My app can play m3u8 stream with exoplayer by switching source array , it does work well on phone but on Android TV it is failed to change channel,
My code is following:
B4X:
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

The picture is error_msg by player_error()
 

Attachments

  • exception.png
    exception.png
    158.8 KB · Views: 171

JohnC

Expert
Licensed User
Longtime User
Try pausing the player before calling tv_play
 
Upvote 0
Top