@Test public void testSessionCallback_onPlaylistChanged() throws InterruptedException { prepareLooper(); final List<MediaItem2> list = TestUtils.createPlaylist(2); final CountDownLatch latch = new CountDownLatch(1); mMockAgent.setPlaylist(list, null); final SessionCallback sessionCallback = new SessionCallback() { @Override public void onPlaylistChanged(MediaSession2 session, MediaPlaylistAgent playlistAgent, List<MediaItem2> playlist, MediaMetadata2 metadata) { assertEquals(mMockAgent, playlistAgent); assertEquals(list, playlist); assertNull(metadata); latch.countDown(); } }; try (MediaSession2 session = new MediaSession2.Builder(mContext) .setPlayer(mPlayer) .setPlaylistAgent(mMockAgent) .setId("testSessionCallback") .setSessionCallback(sHandlerExecutor, sessionCallback) .build()) { mMockAgent.notifyPlaylistChanged(); assertTrue(latch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)); } }
@Override public void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata) { mImpl.setPlaylist(list, metadata); }
MediaSession2 extends MediaInterface2.SessionPlayer implements AutoCloseable { @Override public void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata) { mImpl.setPlaylist(list, metadata); } }
MediaSession2 extends MediaInterface2.SessionPlayer implements AutoCloseable { @Override public void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata) { mImpl.setPlaylist(list, metadata); } MediaSession2(SupportLibraryImpl impl); }
MediaSession2 extends MediaInterface2.SessionPlayer implements AutoCloseable { @Override public void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata) { mImpl.setPlaylist(list, metadata); } MediaSession2(SupportLibraryImpl impl); void updatePlayer(@NonNull MediaPlayerInterface player,
            @Nullable MediaPlaylistAgent playlistAgent,
            @Nullable VolumeProviderCompat volumeProvider); @Override void close(); @NonNull MediaPlayerInterface getPlayer(); @NonNull MediaPlaylistAgent getPlaylistAgent(); @Nullable VolumeProviderCompat getVolumeProvider(); @NonNull SessionToken2 getToken(); @NonNull List<ControllerInfo> getConnectedControllers(); void setAudioFocusRequest(@Nullable AudioFocusRequest afr); void setCustomLayout(@NonNull ControllerInfo controller,
            @NonNull List<CommandButton> layout); void setAllowedCommands(@NonNull ControllerInfo controller,
            @NonNull SessionCommandGroup2 commands); void sendCustomCommand(@NonNull SessionCommand2 command, @Nullable Bundle args); void sendCustomCommand(@NonNull ControllerInfo controller,
            @NonNull SessionCommand2 command, @Nullable Bundle args,
            @Nullable ResultReceiver receiver); @Override void play(); @Override void pause(); @Override void reset(); @Override void prepare(); @Override void seekTo(long pos); @RestrictTo(LIBRARY_GROUP) @Override void skipForward(); @RestrictTo(LIBRARY_GROUP) @Override void skipBackward(); @Override void notifyError(@ErrorCode int errorCode, @Nullable Bundle extras); void notifyRoutesInfoChanged(@NonNull ControllerInfo controller,
            @Nullable List<Bundle> routes); @Override @PlayerState int getPlayerState(); @Override long getCurrentPosition(); @Override long getDuration(); @Override long getBufferedPosition(); @Override @BuffState int getBufferingState(); @Override float getPlaybackSpeed(); @Override void setPlaybackSpeed(float speed); @Override void setOnDataSourceMissingHelper(@NonNull OnDataSourceMissingHelper helper); @Override void clearOnDataSourceMissingHelper(); @Override List<MediaItem2> getPlaylist(); @Override void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata); @Override void skipToPlaylistItem(@NonNull MediaItem2 item); @Override void skipToPreviousItem(); @Override void skipToNextItem(); @Override MediaMetadata2 getPlaylistMetadata(); @Override void addPlaylistItem(int index, @NonNull MediaItem2 item); @Override void removePlaylistItem(@NonNull MediaItem2 item); @Override void replacePlaylistItem(int index, @NonNull MediaItem2 item); @Override MediaItem2 getCurrentMediaItem(); @Override void updatePlaylistMetadata(@Nullable MediaMetadata2 metadata); @Override @RepeatMode int getRepeatMode(); @Override void setRepeatMode(@RepeatMode int repeatMode); @Override @ShuffleMode int getShuffleMode(); @Override void setShuffleMode(@ShuffleMode int shuffleMode); }
MediaSession2 extends MediaInterface2.SessionPlayer implements AutoCloseable { @Override public void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata) { mImpl.setPlaylist(list, metadata); } MediaSession2(SupportLibraryImpl impl); void updatePlayer(@NonNull MediaPlayerInterface player,
            @Nullable MediaPlaylistAgent playlistAgent,
            @Nullable VolumeProviderCompat volumeProvider); @Override void close(); @NonNull MediaPlayerInterface getPlayer(); @NonNull MediaPlaylistAgent getPlaylistAgent(); @Nullable VolumeProviderCompat getVolumeProvider(); @NonNull SessionToken2 getToken(); @NonNull List<ControllerInfo> getConnectedControllers(); void setAudioFocusRequest(@Nullable AudioFocusRequest afr); void setCustomLayout(@NonNull ControllerInfo controller,
            @NonNull List<CommandButton> layout); void setAllowedCommands(@NonNull ControllerInfo controller,
            @NonNull SessionCommandGroup2 commands); void sendCustomCommand(@NonNull SessionCommand2 command, @Nullable Bundle args); void sendCustomCommand(@NonNull ControllerInfo controller,
            @NonNull SessionCommand2 command, @Nullable Bundle args,
            @Nullable ResultReceiver receiver); @Override void play(); @Override void pause(); @Override void reset(); @Override void prepare(); @Override void seekTo(long pos); @RestrictTo(LIBRARY_GROUP) @Override void skipForward(); @RestrictTo(LIBRARY_GROUP) @Override void skipBackward(); @Override void notifyError(@ErrorCode int errorCode, @Nullable Bundle extras); void notifyRoutesInfoChanged(@NonNull ControllerInfo controller,
            @Nullable List<Bundle> routes); @Override @PlayerState int getPlayerState(); @Override long getCurrentPosition(); @Override long getDuration(); @Override long getBufferedPosition(); @Override @BuffState int getBufferingState(); @Override float getPlaybackSpeed(); @Override void setPlaybackSpeed(float speed); @Override void setOnDataSourceMissingHelper(@NonNull OnDataSourceMissingHelper helper); @Override void clearOnDataSourceMissingHelper(); @Override List<MediaItem2> getPlaylist(); @Override void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata); @Override void skipToPlaylistItem(@NonNull MediaItem2 item); @Override void skipToPreviousItem(); @Override void skipToNextItem(); @Override MediaMetadata2 getPlaylistMetadata(); @Override void addPlaylistItem(int index, @NonNull MediaItem2 item); @Override void removePlaylistItem(@NonNull MediaItem2 item); @Override void replacePlaylistItem(int index, @NonNull MediaItem2 item); @Override MediaItem2 getCurrentMediaItem(); @Override void updatePlaylistMetadata(@Nullable MediaMetadata2 metadata); @Override @RepeatMode int getRepeatMode(); @Override void setRepeatMode(@RepeatMode int repeatMode); @Override @ShuffleMode int getShuffleMode(); @Override void setShuffleMode(@ShuffleMode int shuffleMode); static final int ERROR_CODE_UNKNOWN_ERROR; static final int ERROR_CODE_APP_ERROR; static final int ERROR_CODE_NOT_SUPPORTED; static final int ERROR_CODE_AUTHENTICATION_EXPIRED; static final int ERROR_CODE_PREMIUM_ACCOUNT_REQUIRED; static final int ERROR_CODE_CONCURRENT_STREAM_LIMIT; static final int ERROR_CODE_PARENTAL_CONTROL_RESTRICTED; static final int ERROR_CODE_NOT_AVAILABLE_IN_REGION; static final int ERROR_CODE_CONTENT_ALREADY_PLAYING; static final int ERROR_CODE_SKIP_LIMIT_REACHED; static final int ERROR_CODE_ACTION_ABORTED; static final int ERROR_CODE_END_OF_QUEUE; static final int ERROR_CODE_SETUP_REQUIRED; }