I want to be able to know when my radio streaming app is buffering or idle but i kept getting this error.
ERROR
B4X:
Sub Process_Globals
Dim exoplay As SimpleExoPlayer
Dim connect As String = "http://streaming.shoutcast.com/LeafeCodesOnline?lang=en-US%2cen%3bq%3d0.9"
Dim tm As Timer
End Sub
Sub Globals
Private playView As SimpleExoPlayerView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("ui")
playView.Player = exoplay
exoplay.Initialize("exoplay")
exoplay.Prepare(exoplay.CreateUriSource(connect))
exoplay.Play
tm.Initialize ("tm",1000)
tm.Enabled = True
End Sub
Sub exoplay_Ready
Log("Player is ready")
End Sub
Sub exoplay_Error (Message As String)
Log("Error: " & Message)
End Sub
Sub exoplay_complete
Log("complete")
End Sub
Sub exoplay_TrackChanged
Log("Track Changed")
End Sub
Sub tm_Tick
Dim jo As JavaObject = exoplay
Dim state As Int = jo.RunMethod("getPlaybackState", Null)
' 1 = IDLE
' 2 = BUFFERING
' 3 = READY
' 4 = ENDED
Select state
Case 1
Log("IDLE")
Case 2
Log("BUFFERING")
Case 3
Log("READY")
Case 4
Log("ENDED")
End Select
End Sub
ERROR
B4X:
Logger connected to: motorola Moto C Plus
--------- beginning of main
Track Changed
main_tm_tick (java line: 438)
--------- beginning of system
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.onlineradio.main._tm_tick(main.java:438)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
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)
--------- beginning of crash