Android Question Two ExoPlayers at once?

techknight

Well-Known Member
Licensed User
Longtime User
I am trying to create a picture-in-picture type setup with 2 ExoPlayers at once.

I am having a hard time doing this. The first player I initialize takes over the other Exo views. Then if I resize the first player, I can see both movies playing at once together in the same view, even though I am diming 2 different players and assigning them to 2 different windows. Its all messed up. Any ideas?

B4X:
Sub Globals
    Private ForegroundPlayerView As SimpleExoPlayerView
    Private BackgroundPlayerView As SimpleExoPlayerView
    Timer1.Initialize("Timer1",5000)
    Timer1.Enabled = False
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        BackgroundPlayer.Initialize("player")
        ForegroundPlayer.Initialize("player2")
        BackgroundPlayer.Prepare(BackgroundPlayer.CreateLoopSource(BackgroundPlayer.CreateFileSource(File.DirAssets, "blue1.mp4"),-1))
        ForegroundPlayer.Prepare(ForegroundPlayer.CreateLoopSource(ForegroundPlayer.CreateFileSource(File.DirAssets, "sport.mp4"),-1))
    End If
    Activity.LoadLayout("1")
    Sleep(1000)
    ForegroundPlayerView.Player = ForegroundPlayer
    BackgroundPlayerView.Player = BackgroundPlayer
    BackgroundPlayer.Play
'    ForegroundPlayer.Play
    Dim p As PhoneWakeState
    Log("releasing KeepAlive")
    p.ReleaseKeepAlive
    Log("turning screen on")
    p.KeepAlive(True)
    Log("using partialLock")
    p.PartialLock
    Timer1.Enabled = True
End Sub

any thoughts?
 

techknight

Well-Known Member
Licensed User
Longtime User
1. Ive never had a problem with it, all my apps are this way?
2. Again I have never had a problem.

And, I already tried non-overlapping exoplayers, but the 1 video takes over the screens of both customviews. I dont know how to fix this.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Ive never had a problem with it, all my apps are this way?
2. Again I have never had a problem.
Ok. But what I wrote is still correct.

And, I already tried non-overlapping exoplayers, but the 1 video takes over the screens of both customviews. I dont know how to fix this.
Can you upload a small project that demonstrates this issue?
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
1. I am not arguing about whether it is correct or not, you designed the software so you would know better than I would. I am just simply stating that I never had any problems, is all.

2. Sure, but all I did was take the ExoPlayer example and modified it with the code above and the layout. I added a timer which would shrink the background exoplayer and start the 2nd exoplayer (as a test)

Maybe I am making things a bit over-complicated. Here is what I am trying to accomplish:

I am making a news-style ribbon that has an animated graphic as the background, that lays over top of a main video, whether its pre-recorded or (in the end, live).
But the easiest way I found to do the animation is create an exoplayer is the background. But then I cant run a 2nd exoplayer.

My 2nd thought was an animated GIF, but the library uses a timer of interval 0 meaning is going to use all the processing time. Maybe I can shove it in a separate process thread?

I feel like I am over-complicating it, but thats what I am trying to achieve.
 
Last edited:
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
My phone took the Android O Update. Just out of curiosity, I decided to re-run my test app, and now it works perfectly. Video playing on top of a video. I assume the "Picture-in-Picture" they added fixed exoplayer.
 
Upvote 0
Top