Android Question EXOPLAYER skip player to next 'SOURCE'

Rusty

Well-Known Member
Licensed User
Longtime User
In the demo we added several "source" items to be played resulting in a source LIST of items.
As the player plays through the sources, I'd like to be able to click a view (button, combobox, etc.) and have the associated item within the list begin playing from the beginning of that item.
Any ideas/suggestions are appreciated.
Rusty
I've tried to use the ExoPlayerEx example and it abends every time I issue:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Cannot get methods of class: com.google.android.exoplayer2.SimpleExoPlayer, disabling cache.
Error occurred on line: 20 (ExoPlayerExtra)
java.lang.NullPointerException
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:343)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:119)
at b4a.example.exoplayerextra._getwindowcount(exoplayerextra.java:112)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
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.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1083)
at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1046)
at b4a.example3.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:803)
at b4a.example3.customlistview._panelclickhandler(customlistview.java:746)
at b4a.example3.customlistview._panel_click(customlistview.java:733)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
B4X:
Sub Activity_Create(FirstTime As Boolean)
 Activity.LoadLayout("1")

    Player.Initialize("Player")
    sources.Initialize
    For i = 1 To 31            'load the audio files
        Dim FileNumber As String = ZeroFill(i, True, 3)
        Dim Filename As String = "File_001_" & FileNumber & ".mp3"
        sources.Add(Player.CreateFileSource(File.DirAssets, Filename))
    Next
    Player.Prepare(Player.CreateListSource(sources))
        Player.Play
        PlayerEx.Intialize(Player)
…
End Sub

INDEX here indicates the row within the CustomListview1 that represents this audio file
Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    Player.Initialize("Player")
    PlayerEx.CurrentWindowIndex =  (Index + 1) Mod PlayerEx.WindowCount       'it blows up here with a null reference
    Player.Play
End Sub
 

Rusty

Well-Known Member
Licensed User
Longtime User
...sorry, that was a residual from a previous attempt to initialize the player; clear the sources; reload the sources; prepare and play...
The second initialization wasn't supposed to be there...
The mentioned attempt works, but it seems very inefficient, so I was trying to use the PlayerEx to move/position.
The question still stands sans the initialization :)
But now it blows up in the ExoPlayerExtra:
Ready
Cannot get methods of class: com.google.android.exoplayer2.SimpleExoPlayer, disabling cache.
Error occurred on line: 20 (ExoPlayerExtra)
java.lang.NullPointerException
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:343)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:119)
at b4a.example.exoplayerextra._getwindowcount(exoplayerextra.java:86)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
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.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1083)
at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1046)
at b4a.example3.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:803)
at b4a.example3.customlistview._panelclickhandler(customlistview.java:746)
at b4a.example3.customlistview._panel_click(customlistview.java:733)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:4565)
at android.view.View$PerformClick.run(View.java:18641)
 
Upvote 0
Top