Android Question Exoplayer event capture error

Scantech

Well-Known Member
Licensed User
Longtime User

This was the code used back in 2020. It has an error now with com/google/android/exoplayer2/ui/PlayerControlView.VisibilityListener".Replace("/", ".")

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    player1.Initialize("player1")
    SimpleExoPlayerView1.Player = player1
    Dim sources As List
    sources.Initialize
    sources.Add(player1.CreateUriSource("https://html5demos.com/assets/dizzy.mp4"))
    player1.Prepare(player1.CreateListSource(sources))
    Dim jo As JavaObject = SimpleExoPlayerView1
    Dim event As Object = jo.CreateEventFromUI("com/google/android/exoplayer2/ui/PlayerControlView.VisibilityListener".Replace("/", "."), "VisibilityChange", Null)
    jo.RunMethod("setControllerVisibilityListener", Array(event))
End Sub

[QUOTE]

[/QUOTE]

Sub VisibilityChange_Event (MethodName As String, Args() As Object) As Object
    Dim IsVisible As Boolean = 0 = Args(0)
    Log("Visible: " & IsVisible)
    Return Null
End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
    Dim jo As JavaObject = SimpleExoPlayerView1
    Dim event As Object = jo.CreateEventFromUI("androidx.media3.ui.PlayerView.ControllerVisibilityListener", "VisibilityChange", Null)
    jo.RunMethod("setControllerVisibilityListener", Array(event))

Sub VisibilityChange_Event (MethodName As String, Args() As Object) As Object
    Dim IsVisible As Boolean = 0 = Args(0)
    Log("Visible: " & IsVisible)
    Return Null
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…