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;
}
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;
}
Aggregations