Android Question Full screen Exoplayer can't use simpleexoplayer

Scantech

Well-Known Member
Licensed User
Longtime User
The full screen exoplayer by erel will not allow me to use the simpleexoplayer. There is no simpleexoplayer global declaration. How do i make use of the simpleexoplayer. It contains a switchtargetview.

Full Screen Demo

B4X:
Private Sub SwitchTargetPlayerView(FullScreenIsDestination As Boolean)
    Dim mp As B4XPage3 = B4XPages.GetPage("Media Player")
 
    Dim jo As JavaObject
    Dim Player As Object = mp.Player.As(JavaObject).GetField("player")
    jo.InitializeStatic("androidx.media3.ui.PlayerView")
    jo.RunMethod("switchTargetView", Array(Player, IIf(FullScreenIsDestination, mp.SimpleExoPlayerView1, SimpleExoPlayerView1), IIf(FullScreenIsDestination, SimpleExoPlayerView1, mp.SimpleExoPlayerView1)))
End Sub
 

Scantech

Well-Known Member
Licensed User
Longtime User
I found a solution as per below
B4X:
Sub Globals
    Private SimpleExoPlayerView1 As SimpleExoPlayerView
    Private Player2 As SimpleExoPlayer
    Dim mp As B4XPage3
End Sub

B4X:
 Sub Activity_Create(FirstTime As Boolean) 
    Player2.Initialize("player")
    SwitchTargetPlayerView(True)
    Player2 = mp.Player

End Sub

Private Sub SwitchTargetPlayerView(FullScreenIsDestination As Boolean)
    mp = B4XPages.GetPage("Media Player")
 
    Dim jo As JavaObject
    Dim Player As Object = mp.Player.As(JavaObject).GetField("player")
    jo.InitializeStatic("androidx.media3.ui.PlayerView")
    jo.RunMethod("switchTargetView", Array(Player, IIf(FullScreenIsDestination, mp.SimpleExoPlayerView1, SimpleExoPlayerView1), IIf(FullScreenIsDestination, SimpleExoPlayerView1, mp.SimpleExoPlayerView1)))
End Sub
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
That solution is in the demo!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…