Android Question Exoplayer event capture error

Scantech

Well-Known Member
Licensed User
Longtime User
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Receiver (httputils2service) Receive (first time) ***
JobName = Job, Success = true
JobTag = Download Arabic
Channel 11
408
Error occurred on line: 38 (B4XPage3)
java.lang.ClassNotFoundException: com.google.android.exoplayer2$ui$PlayerControlView$VisibilityListener
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:289)
at anywheresoftware.b4j.object.JavaObject.createEvent(JavaObject.java:253)
at anywheresoftware.b4j.object.JavaObject.CreateEventFromUI(JavaObject.java:223)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at scantech.iptv.b4xpage3._b4xpage_created(b4xpage3.java:177)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
at scantech.iptv.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1072)
at scantech.iptv.b4xpagesmanager._showpage(b4xpagesmanager.java:429)
at scantech.iptv.b4xpages._showpage(b4xpages.java:72)
at scantech.iptv.b4xpage2._paneltext_click(b4xpage2.java:692)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

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
Top