Android Question detect buffer event while exoplayer is buffering

analizer3816

Member
Licensed User
Longtime User
I want to show loading icon while exoplayer is buffering data from streaming media, but exoplayer has 3 events(ready,error,complete) only.how I detect buffer event?

thanks
 

analizer3816

Member
Licensed User
Longtime User
thanks, now I use exoplayer in service and create eventlistener.
it works well in debug mode, but log show "Unexpected event (missing RaiseSynchronousEvents): check_event"

I try add #RaisesSynchronousEvents: check_event
and test app in release mode, not work!

player1 must run in service because I want to play in background
please suggest me.

B4X:
Sub create_event
    Dim jo As JavaObject = player1
    jo = jo.GetField("player")
    Dim e As Object = jo.CreateEvent("com.google.android.exoplayer2.ExoPlayer.EventListener", "check", False)
    jo.RunMethod("addListener", Array As Object(e))
End Sub

B4X:
Sub check_event (MethodName As String, Args() As Object) As Object
    Log(MethodName)
    If(MethodName = "onPlayerStateChanged") Then Player_onPlayerStateChanged(Args(0), Args(1))
    If(MethodName = "onLoadingChanged") Then Player_onLoadingChanged(Args(0))
    If(MethodName = "onTimelineChanged") Then Player_onTimelineChanged(Args(0), Args(1))
    If(MethodName = "onPositionDiscontinuity") Then Player_onPositionDiscontinuity
    Return True
End Sub
 

Attachments

  • 1.zip
    8.2 KB · Views: 382
Last edited:
Upvote 0

analizer3816

Member
Licensed User
Longtime User
ok, but
in release mode, no event was detected via check_event
in debug mode, all event was detected
I don't understand about this

could you check my code in 1.zip ?
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
I am trying to check if exoplayer is buffering with this code in the timer tick event but i kept getting error
Dim jo As JavaObject = ExoPlayer1
Dim state As Int = jo.RunMethod("getPlaybackState", Null)

ERROR
B4X:
Logger connected to: ZW2223G5RT
--------- beginning of system
--------- beginning of crash
--------- beginning of main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
main$ResumableSub_tm_Tickresume (java line: 867)
java.lang.RuntimeException: Method: getPlaybackState not found in: anywheresoftware.b4a.objects.SimpleExoPlayerWrapper
    at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:366)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:119)
    at com.leafecodes.missionsradio.main$ResumableSub_tm_Tick.resume(main.java:867)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:245)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:185)
    at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1154)
    at android.os.Handler.handleCallback(Handler.java:836)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:203)
    at android.app.ActivityThread.main(ActivityThread.java:6251)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1075)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
 
Upvote 0
Top