Android Question Exoplayer Loop function

Ricardo Bunschoten

Active Member
Licensed User
Longtime User
If u use a Http:// source like

B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
player1.Initialize("player")
Dim sources As List
sources.Initialize
sources.Add(player1.CreateUriSource("http://192.168.178.16/video/film.mp4"))
player1.Prepare(player1.CreateListSource(sources))
Can i still use the loop function ?


Because this code i found on the forum uses a listsource instead of a Urisource ?
B4X:
Dim ListSource As Object = player1.CreateListSource(sources)
player1.Prepare(player1.CreateLoopSource(ListSource, -1))
So i am a little confused on how to use the loop function on a urisource ?
 

Ricardo Bunschoten

Active Member
Licensed User
Longtime User
I tried this

B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        player1.Initialize("player")
        Dim sources As List
        sources.Initialize
        sources.Add(player1.CreateUriSource("http://192.168.178.16/video/film.mp4"))
        player1.Prepare(player1.CreateLoopSource(sources, -1))
    End If
    Activity.LoadLayout("1")
    SimpleExoPlayerView1.Player = player1
    player1.Play
End Sub

Sources is the source of course and the -1 is for the infinite loop

But the app starts and stop immediately ?

Is the syntax wrong ?
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Try to change this code:
B4X:
sources.Add(player1.CreateUriSource("http://192.168.178.16/video/film.mp4"))
player1.Prepare(player1.CreateLoopSource(sources, -1))
to this:
B4X:
sources.Add(player1.CreateUriSource("http://192.168.178.16/video/film.mp4"))
Dim ListSource As Object = player1.CreateListSource(sources)
player1.Prepare(player1.CreateLoopSource(sources, -1))
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Ricardo Bunschoten

Active Member
Licensed User
Longtime User
Try to change this code:
B4X:
sources.Add(player1.CreateUriSource("http://192.168.178.16/video/film.mp4"))
player1.Prepare(player1.CreateLoopSource(sources, -1))
to this:
B4X:
sources.Add(player1.CreateUriSource("http://192.168.178.16/video/film.mp4"))
Dim ListSource As Object = player1.CreateListSource(sources)
player1.Prepare(player1.CreateLoopSource(sources, -1))
That Don't works i get a error that variable listsource is not used
 
Upvote 0

Ricardo Bunschoten

Active Member
Licensed User
Longtime User
I tried this

B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        player1.Initialize("player")
        Dim sources As List
        sources.Initialize
        sources.Add(player1.CreateUriSource("http://192.168.178.16/video/film.mp4"))
        player1.Prepare(player1.CreateLoopSource(sources, -1))
    End If
    Activity.LoadLayout("1")
    SimpleExoPlayerView1.Player = player1
    player1.Play
End Sub

Sources is the source of course and the -1 is for the infinite loop

But the app starts and stop immediately ?

Is the syntax wrong ?
When i use a other url then it also quits direct. So it's not the url.
 
Upvote 0

ac9ts

Active Member
Licensed User
Longtime User
Referencing https://www.b4x.com/android/forum/threads/exoplayer-infinite-loop-of-sourcelist.82397/post-521771

B4X:
Sub Activity_Create(FirstTime As Boolean)
    
    If FirstTime Then
        player1.Initialize("player")
        Dim sources As List
        sources.Initialize
        sources.Add(player1.CreateUriSource("https://html5demos.com/assets/dizzy.mp4"))
        sources.Add(player1.CreateUriSource("http://archive.org/download/YoutubeVideo0145ShortClipLawnMower/Youtube%20video%200145%20short%20clip%20Lawn%20Mower.mp4"))
        sources.Add(player1.CreateUriSource("http://archive.org/download/ichmp4andflv6Test/9.mp4"))
        sources.Add(player1.CreateUriSource("http://archive.org/download/drascii/drascii.mp4"))
        sources.Add(player1.CreateUriSource("http://archive.org/download/Dig_Dug_1982_Atari_US.mp4/Dig_Dug_1982_Atari_US.mp4"))
        
        Dim ListSource As Object = player1.CreateListSource(sources) '<<<<<<<<<<<<<<<<<<<<<<<
        player1.Prepare(player1.CreateLoopSource(ListSource, -1))

    End If
    Activity.LoadLayout("1")
    SimpleExoPlayerView1.Player = player1
    player1.Play
    
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The log only says Logger connected to: OPPO CPH1919
This is the real problem. You must be able to read the logs.
On some devices you need to enable the logs on the developer options. If you don't see the logs with B4A-Bridge then try to switch to USB debug mode.
 
Upvote 0

Ricardo Bunschoten

Active Member
Licensed User
Longtime User
This is the real problem. You must be able to read the logs.
On some devices you need to enable the logs on the developer options. If you don't see the logs with B4A-Bridge then try to switch to USB debug mode.
Thnx Erel it's working now reinstalled my Windows and now it works fine.
 
Upvote 0
Top