Search in sources :

Example 11 with MediaMetadata

use of androidx.media2.common.MediaMetadata in project ExoPlayer by google.

the class SessionPlayerConnector method setPlaylist.

/**
 * {@inheritDoc}
 *
 * <p>{@link FileMediaItem} and {@link CallbackMediaItem} are not supported.
 */
@Override
public ListenableFuture<PlayerResult> setPlaylist(final List<MediaItem> playlist, @Nullable MediaMetadata metadata) {
    Assertions.checkNotNull(playlist);
    Assertions.checkArgument(!playlist.isEmpty());
    for (int i = 0; i < playlist.size(); i++) {
        MediaItem item = playlist.get(i);
        Assertions.checkNotNull(item);
        Assertions.checkArgument(!(item instanceof FileMediaItem));
        Assertions.checkArgument(!(item instanceof CallbackMediaItem));
        for (int j = 0; j < i; j++) {
            Assertions.checkArgument(item != playlist.get(j), "playlist shouldn't contain duplicated item, index=" + i + " vs index=" + j);
        }
    }
    ListenableFuture<PlayerResult> result = playerCommandQueue.addCommand(PlayerCommandQueue.COMMAND_CODE_PLAYER_SET_PLAYLIST, /* command= */
    () -> player.setPlaylist(playlist, metadata));
    return result;
}
Also used : CallbackMediaItem(androidx.media2.common.CallbackMediaItem) MediaItem(androidx.media2.common.MediaItem) FileMediaItem(androidx.media2.common.FileMediaItem) CallbackMediaItem(androidx.media2.common.CallbackMediaItem) FileMediaItem(androidx.media2.common.FileMediaItem)

Aggregations

MediaItem (androidx.media2.common.MediaItem)10 MediaMetadata (androidx.media2.common.MediaMetadata)9 SessionPlayer (androidx.media2.common.SessionPlayer)8 UriMediaItem (androidx.media2.common.UriMediaItem)8 LargeTest (androidx.test.filters.LargeTest)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 Test (org.junit.Test)8 MediumTest (androidx.test.filters.MediumTest)7 SmallTest (androidx.test.filters.SmallTest)7 ArrayList (java.util.ArrayList)5 CallbackMediaItem (androidx.media2.common.CallbackMediaItem)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 FileMediaItem (androidx.media2.common.FileMediaItem)2 Context (android.content.Context)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 TextUtils (android.text.TextUtils)1 Nullable (androidx.annotation.Nullable)1 ContextCompat (androidx.core.content.ContextCompat)1 Rating (androidx.media2.common.Rating)1