Search in sources :

Example 26 with MediaItem

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

the class SessionPlayerConnector method getBufferingState.

@Override
public /* @BuffState */
int getBufferingState() {
    @Nullable MediaItem mediaItem = this.<@NullableType MediaItem>runPlayerCallableBlocking(/* callable= */
    player::getCurrentMediaItem, /* defaultValueWhenException= */
    null);
    if (mediaItem == null) {
        return BUFFERING_STATE_UNKNOWN;
    }
    @Nullable Integer buffState;
    synchronized (stateLock) {
        buffState = mediaItemToBuffState.get(mediaItem);
    }
    return buffState == null ? BUFFERING_STATE_UNKNOWN : buffState;
}
Also used : CallbackMediaItem(androidx.media2.common.CallbackMediaItem) MediaItem(androidx.media2.common.MediaItem) FileMediaItem(androidx.media2.common.FileMediaItem) Nullable(androidx.annotation.Nullable)

Example 27 with MediaItem

use of androidx.media2.common.MediaItem 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)22 UriMediaItem (androidx.media2.common.UriMediaItem)18 LargeTest (androidx.test.filters.LargeTest)16 Test (org.junit.Test)16 SessionPlayer (androidx.media2.common.SessionPlayer)15 CountDownLatch (java.util.concurrent.CountDownLatch)14 MediumTest (androidx.test.filters.MediumTest)13 SmallTest (androidx.test.filters.SmallTest)13 ArrayList (java.util.ArrayList)13 MediaMetadata (androidx.media2.common.MediaMetadata)11 CallbackMediaItem (androidx.media2.common.CallbackMediaItem)9 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)9 Nullable (androidx.annotation.Nullable)7 FileMediaItem (androidx.media2.common.FileMediaItem)5 Uri (android.net.Uri)4 SessionCommand (androidx.media2.session.SessionCommand)4 SessionCommandGroup (androidx.media2.session.SessionCommandGroup)4 List (java.util.List)4 Context (android.content.Context)3 Bundle (android.os.Bundle)3