I need to update the playlist of the ExoPlayer to append new media files as they arrive from a download service, without interrupting the currently playing track. To do this, I append each new file to the playlist of sources:
and then I call the:
The problem is that after call Player.Prepare(), the playback of the current track is stopped and the current track is changed to the first track of the updated playlist.
I read in the documentation of the java ExoPlayer object that:
"It’s possible to dynamically modify a playlist by adding, removing and moving MediaSources within a ConcatenatingMediaSource. This can be done both before and during playback by calling the corresponding ConcatenatingMediaSource methods. The player automatically handles modifications during playback in the correct way. For example if the currently playing MediaSource is moved, playback is not interrupted and its new successor will be played upon completion. If the currently playing MediaSource is removed, the player will automatically move to playing the first remaining successor, or transition to the ended state if no such successor exists."
How is it possibile to implement this functionality in B4A, "extending" in same way the B4A ExoPlayer library?
I would like to implement a direct access to the ExoPlayer methods to dynamically modify the playlist, something like that Erel showed in the code:
B4X:
PlayerPlayList.Add(Player.CreateFileSource(dir, f))
B4X:
Player.Prepare(Player.CreateListSource(PlayerPlayList))
I read in the documentation of the java ExoPlayer object that:
"It’s possible to dynamically modify a playlist by adding, removing and moving MediaSources within a ConcatenatingMediaSource. This can be done both before and during playback by calling the corresponding ConcatenatingMediaSource methods. The player automatically handles modifications during playback in the correct way. For example if the currently playing MediaSource is moved, playback is not interrupted and its new successor will be played upon completion. If the currently playing MediaSource is removed, the player will automatically move to playing the first remaining successor, or transition to the ended state if no such successor exists."
How is it possibile to implement this functionality in B4A, "extending" in same way the B4A ExoPlayer library?
I would like to implement a direct access to the ExoPlayer methods to dynamically modify the playlist, something like that Erel showed in the code:
B4X:
Sub Class_Globals
Public Player As SimpleExoPlayer
Private jPlayer As JavaObject
...
End Sub
Public Sub Initialize
Player.Initialize("PLAYER")
jPlayer = Player
jPlayer = jPlayer.GetField("player")
...
End Sub
Private Sub jgetWindowCount As Int
Dim timeline As JavaObject = jPlayer.RunMethod("getCurrentTimeline", Null)
Return timeline.RunMethod("getWindowCount", Null)
End Sub