Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid assertions in SessionPlayerConnector #8047

Closed
georgi-neykov-hub opened this issue Oct 6, 2020 · 6 comments
Closed

Invalid assertions in SessionPlayerConnector #8047

georgi-neykov-hub opened this issue Oct 6, 2020 · 6 comments
Assignees
Labels

Comments

@georgi-neykov-hub
Copy link

[REQUIRED] Issue description

I am using the new media2 extension for Exoplayer (v2.12.0) and I am trying to use the new playlist APIs in a Player connected via a SessionPlayerConnector to a MediaLibrarySession. The SessionPlayer APIs from AndroidX prohibit calling SessionPlayer.setMediaItem with a null MediaItem argument and calling SessionPlayer.setPlaylist() with a null or empty List<MediaItem>, but is perfectly fine to call SessionPlayer.removeMediaItem() until the playlist is empty.

In my use case I want to update the playlist of a given ExoPlayer instance with a diff change script (add/remove/change/move) applied via the existing Player playlist modification APIs.
Everything is mostly fine (#8046 ) until the playlist goes empty and an assertion in SessionPlayerConnector.handlePlaylistChangedOnHandler() kicks in:

...
if (notifyCurrentMediaItem) {
            Assertions.checkNotNull(
                currentMediaItem, "PlaylistManager#currentMediaItem() cannot be changed to null");

            callback.onCurrentMediaItemChanged(SessionPlayerConnector.this, currentMediaItem);
...

The code above results in inability to have the player playlist cleared either directly via the com.google.android.exoplayer2.Player or the APIs from androidx.media2.common.SessionPlayer and have the updates to state reported to media2 related classes.

Having this issue together with (#8011) greatly makes the extension unusable if someone wants to use both the playlist APIs and media2 extension introduced in 2.12.0.

[REQUIRED] Reproduction steps

  1. Instantiate and configure a MediaSession, link it to a SessionPlayerConnector with a Player instance
  2. Add playlist items to the Player, either directly or via the SessionPlayer API
  3. Clear the playlist directly through the Player, or by calling SessionPlayer.removeMediaItem(0) until the playlist is empty.

[REQUIRED] Link to test content

The issue is not related to media file decoding or playback.

[REQUIRED] A full bug report captured from the device

assertion stacktrace.txt

[REQUIRED] Version of ExoPlayer being used

2.12.0

[REQUIRED] Device(s) and version(s) of Android being used

Any Android-powered device or emulator complying with the minSdk of the Exoplayer library.

@tonihei
Copy link
Collaborator

tonihei commented Oct 6, 2020

@sim0629 Could you take a look?

@sim0629 sim0629 assigned SungsooLim and unassigned sim0629 Oct 8, 2020
@sim0629
Copy link
Contributor

sim0629 commented Oct 8, 2020

I'll be on leave from tomorrow. Sungsoo, could you take a look?

@ojw28
Copy link
Contributor

ojw28 commented Oct 13, 2020

@SungsooLim - We should try and get this fixed for a minor release. It's a bit unclear what SessionPlayer.PlayerCallback. onCurrentMediaItemChanged should be called with when the playlist becomes empty. Should it be sent an empty MediaItem?

@SungsooLim
Copy link

When MediaItem or Playlist becomes becomes null or empty, then the state of SessionPlayer should become idle.
Let me investigate and think a little more for the current status and the proper fix.

@SungsooLim
Copy link

Fixed.

@ojw28
Copy link
Contributor

ojw28 commented Nov 20, 2020

Fixed in 2f1c0a5. This will be included in the 2.12.2 release, which is due in the next couple of weeks.

@google google locked and limited conversation to collaborators Jan 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants