Android Question timebar(seekbar) exoplayer addListener

Erel

Administrator
Staff member
Licensed User
A bit brute force:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    player1.Initialize("player")
    Dim sources As List
    sources.Initialize
    sources.Add(player1.CreateUriSource("https://html5demos.com/assets/dizzy.mp4"))
    player1.Prepare(player1.CreateListSource(sources))
    SimpleExoPlayerView1.Player = player1
    Dim r As Reflector
    r.Target = SimpleExoPlayerView1
    
    r.Target = r.GetField("controller")
    Dim timebar As JavaObject = r.GetField("timeBar")
    Dim listener As Object = timebar.CreateEventFromUI("com.google.android.exoplayer2.ui.TimeBar$OnScrubListener", "Scrub", False)
    timebar.RunMethod("addListener", Array(listener))
End Sub

Sub Scrub_Event (MethodName As String, Args() As Object) As Object
    Log(MethodName)
    If MethodName.Contains("Scrub") Then
        Dim position As Long = Args(1)
        Log(position)
    End If
    Return False
End Sub
 
Upvote 0
Top