mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Merge branch 'dev-v2' of https://github.com/google/ExoPlayer into dev-v2
This commit is contained in:
commit
30cfc3c6c4
31 changed files with 1228 additions and 1019 deletions
|
|
@ -85,6 +85,10 @@
|
||||||
* RTMP extension:
|
* RTMP extension:
|
||||||
* Upgrade to `io.antmedia:rtmp_client`, which does not rely on `jcenter()`
|
* Upgrade to `io.antmedia:rtmp_client`, which does not rely on `jcenter()`
|
||||||
([#9591](https://github.com/google/ExoPlayer/issues/9591)).
|
([#9591](https://github.com/google/ExoPlayer/issues/9591)).
|
||||||
|
* MediaSession extension:
|
||||||
|
* Rename
|
||||||
|
`MediaSessionConnector.QueueNavigator#onCurrentWindowIndexChanged` to
|
||||||
|
`onCurrentMediaItemIndexChanged`.
|
||||||
* Remove deprecated symbols:
|
* Remove deprecated symbols:
|
||||||
* Remove `Renderer.VIDEO_SCALING_MODE_*` constants. Use identically named
|
* Remove `Renderer.VIDEO_SCALING_MODE_*` constants. Use identically named
|
||||||
constants in `C` instead.
|
constants in `C` instead.
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ import java.util.ArrayList;
|
||||||
int playbackState = currentPlayer.getPlaybackState();
|
int playbackState = currentPlayer.getPlaybackState();
|
||||||
maybeSetCurrentItemAndNotify(
|
maybeSetCurrentItemAndNotify(
|
||||||
playbackState != Player.STATE_IDLE && playbackState != Player.STATE_ENDED
|
playbackState != Player.STATE_IDLE && playbackState != Player.STATE_ENDED
|
||||||
? currentPlayer.getCurrentWindowIndex()
|
? currentPlayer.getCurrentMediaItemIndex()
|
||||||
: C.INDEX_UNSET);
|
: C.INDEX_UNSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -281,7 +281,7 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
// Player state management.
|
// Player state management.
|
||||||
long playbackPositionMs = C.TIME_UNSET;
|
long playbackPositionMs = C.TIME_UNSET;
|
||||||
int windowIndex = C.INDEX_UNSET;
|
int currentItemIndex = C.INDEX_UNSET;
|
||||||
boolean playWhenReady = false;
|
boolean playWhenReady = false;
|
||||||
|
|
||||||
Player previousPlayer = this.currentPlayer;
|
Player previousPlayer = this.currentPlayer;
|
||||||
|
|
@ -291,10 +291,10 @@ import java.util.ArrayList;
|
||||||
if (playbackState != Player.STATE_ENDED) {
|
if (playbackState != Player.STATE_ENDED) {
|
||||||
playbackPositionMs = previousPlayer.getCurrentPosition();
|
playbackPositionMs = previousPlayer.getCurrentPosition();
|
||||||
playWhenReady = previousPlayer.getPlayWhenReady();
|
playWhenReady = previousPlayer.getPlayWhenReady();
|
||||||
windowIndex = previousPlayer.getCurrentWindowIndex();
|
currentItemIndex = previousPlayer.getCurrentMediaItemIndex();
|
||||||
if (windowIndex != currentItemIndex) {
|
if (currentItemIndex != this.currentItemIndex) {
|
||||||
playbackPositionMs = C.TIME_UNSET;
|
playbackPositionMs = C.TIME_UNSET;
|
||||||
windowIndex = currentItemIndex;
|
currentItemIndex = this.currentItemIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previousPlayer.stop();
|
previousPlayer.stop();
|
||||||
|
|
@ -304,7 +304,7 @@ import java.util.ArrayList;
|
||||||
this.currentPlayer = currentPlayer;
|
this.currentPlayer = currentPlayer;
|
||||||
|
|
||||||
// Media queue management.
|
// Media queue management.
|
||||||
currentPlayer.setMediaItems(mediaQueue, windowIndex, playbackPositionMs);
|
currentPlayer.setMediaItems(mediaQueue, currentItemIndex, playbackPositionMs);
|
||||||
currentPlayer.setPlayWhenReady(playWhenReady);
|
currentPlayer.setPlayWhenReady(playWhenReady);
|
||||||
currentPlayer.prepare();
|
currentPlayer.prepare();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
// Saved instance state keys.
|
// Saved instance state keys.
|
||||||
|
|
||||||
private static final String KEY_TRACK_SELECTION_PARAMETERS = "track_selection_parameters";
|
private static final String KEY_TRACK_SELECTION_PARAMETERS = "track_selection_parameters";
|
||||||
private static final String KEY_WINDOW = "window";
|
private static final String KEY_ITEM_INDEX = "item_index";
|
||||||
private static final String KEY_POSITION = "position";
|
private static final String KEY_POSITION = "position";
|
||||||
private static final String KEY_AUTO_PLAY = "auto_play";
|
private static final String KEY_AUTO_PLAY = "auto_play";
|
||||||
|
|
||||||
|
|
@ -83,7 +83,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
private DebugTextViewHelper debugViewHelper;
|
private DebugTextViewHelper debugViewHelper;
|
||||||
private TracksInfo lastSeenTracksInfo;
|
private TracksInfo lastSeenTracksInfo;
|
||||||
private boolean startAutoPlay;
|
private boolean startAutoPlay;
|
||||||
private int startWindow;
|
private int startItemIndex;
|
||||||
private long startPosition;
|
private long startPosition;
|
||||||
|
|
||||||
// For ad playback only.
|
// For ad playback only.
|
||||||
|
|
@ -114,7 +114,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
DefaultTrackSelector.Parameters.CREATOR.fromBundle(
|
DefaultTrackSelector.Parameters.CREATOR.fromBundle(
|
||||||
savedInstanceState.getBundle(KEY_TRACK_SELECTION_PARAMETERS));
|
savedInstanceState.getBundle(KEY_TRACK_SELECTION_PARAMETERS));
|
||||||
startAutoPlay = savedInstanceState.getBoolean(KEY_AUTO_PLAY);
|
startAutoPlay = savedInstanceState.getBoolean(KEY_AUTO_PLAY);
|
||||||
startWindow = savedInstanceState.getInt(KEY_WINDOW);
|
startItemIndex = savedInstanceState.getInt(KEY_ITEM_INDEX);
|
||||||
startPosition = savedInstanceState.getLong(KEY_POSITION);
|
startPosition = savedInstanceState.getLong(KEY_POSITION);
|
||||||
} else {
|
} else {
|
||||||
trackSelectionParameters =
|
trackSelectionParameters =
|
||||||
|
|
@ -206,7 +206,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
updateStartPosition();
|
updateStartPosition();
|
||||||
outState.putBundle(KEY_TRACK_SELECTION_PARAMETERS, trackSelectionParameters.toBundle());
|
outState.putBundle(KEY_TRACK_SELECTION_PARAMETERS, trackSelectionParameters.toBundle());
|
||||||
outState.putBoolean(KEY_AUTO_PLAY, startAutoPlay);
|
outState.putBoolean(KEY_AUTO_PLAY, startAutoPlay);
|
||||||
outState.putInt(KEY_WINDOW, startWindow);
|
outState.putInt(KEY_ITEM_INDEX, startItemIndex);
|
||||||
outState.putLong(KEY_POSITION, startPosition);
|
outState.putLong(KEY_POSITION, startPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -282,9 +282,9 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
debugViewHelper = new DebugTextViewHelper(player, debugTextView);
|
debugViewHelper = new DebugTextViewHelper(player, debugTextView);
|
||||||
debugViewHelper.start();
|
debugViewHelper.start();
|
||||||
}
|
}
|
||||||
boolean haveStartPosition = startWindow != C.INDEX_UNSET;
|
boolean haveStartPosition = startItemIndex != C.INDEX_UNSET;
|
||||||
if (haveStartPosition) {
|
if (haveStartPosition) {
|
||||||
player.seekTo(startWindow, startPosition);
|
player.seekTo(startItemIndex, startPosition);
|
||||||
}
|
}
|
||||||
player.setMediaItems(mediaItems, /* resetPosition= */ !haveStartPosition);
|
player.setMediaItems(mediaItems, /* resetPosition= */ !haveStartPosition);
|
||||||
player.prepare();
|
player.prepare();
|
||||||
|
|
@ -382,14 +382,14 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
private void updateStartPosition() {
|
private void updateStartPosition() {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
startAutoPlay = player.getPlayWhenReady();
|
startAutoPlay = player.getPlayWhenReady();
|
||||||
startWindow = player.getCurrentWindowIndex();
|
startItemIndex = player.getCurrentMediaItemIndex();
|
||||||
startPosition = Math.max(0, player.getContentPosition());
|
startPosition = Math.max(0, player.getContentPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void clearStartPosition() {
|
protected void clearStartPosition() {
|
||||||
startAutoPlay = true;
|
startAutoPlay = true;
|
||||||
startWindow = C.INDEX_UNSET;
|
startItemIndex = C.INDEX_UNSET;
|
||||||
startPosition = C.TIME_UNSET;
|
startPosition = C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -318,9 +318,9 @@ public final class CastPlayer extends BasePlayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition) {
|
public void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition) {
|
||||||
int windowIndex = resetPosition ? 0 : getCurrentWindowIndex();
|
int mediaItemIndex = resetPosition ? 0 : getCurrentMediaItemIndex();
|
||||||
long startPositionMs = resetPosition ? C.TIME_UNSET : getContentPosition();
|
long startPositionMs = resetPosition ? C.TIME_UNSET : getContentPosition();
|
||||||
setMediaItems(mediaItems, windowIndex, startPositionMs);
|
setMediaItems(mediaItems, mediaItemIndex, startPositionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -443,7 +443,7 @@ public final class CastPlayer extends BasePlayer {
|
||||||
// in RemoteMediaClient.
|
// in RemoteMediaClient.
|
||||||
positionMs = positionMs != C.TIME_UNSET ? positionMs : 0;
|
positionMs = positionMs != C.TIME_UNSET ? positionMs : 0;
|
||||||
if (mediaStatus != null) {
|
if (mediaStatus != null) {
|
||||||
if (getCurrentWindowIndex() != mediaItemIndex) {
|
if (getCurrentMediaItemIndex() != mediaItemIndex) {
|
||||||
remoteMediaClient
|
remoteMediaClient
|
||||||
.queueJumpToItem(
|
.queueJumpToItem(
|
||||||
(int) currentTimeline.getPeriod(mediaItemIndex, period).uid, positionMs, null)
|
(int) currentTimeline.getPeriod(mediaItemIndex, period).uid, positionMs, null)
|
||||||
|
|
@ -636,7 +636,7 @@ public final class CastPlayer extends BasePlayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCurrentPeriodIndex() {
|
public int getCurrentPeriodIndex() {
|
||||||
return getCurrentWindowIndex();
|
return getCurrentMediaItemIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1103,15 +1103,15 @@ public final class CastPlayer extends BasePlayer {
|
||||||
@Nullable
|
@Nullable
|
||||||
private PendingResult<MediaChannelResult> setMediaItemsInternal(
|
private PendingResult<MediaChannelResult> setMediaItemsInternal(
|
||||||
MediaQueueItem[] mediaQueueItems,
|
MediaQueueItem[] mediaQueueItems,
|
||||||
int startWindowIndex,
|
int startIndex,
|
||||||
long startPositionMs,
|
long startPositionMs,
|
||||||
@RepeatMode int repeatMode) {
|
@RepeatMode int repeatMode) {
|
||||||
if (remoteMediaClient == null || mediaQueueItems.length == 0) {
|
if (remoteMediaClient == null || mediaQueueItems.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
startPositionMs = startPositionMs == C.TIME_UNSET ? 0 : startPositionMs;
|
startPositionMs = startPositionMs == C.TIME_UNSET ? 0 : startPositionMs;
|
||||||
if (startWindowIndex == C.INDEX_UNSET) {
|
if (startIndex == C.INDEX_UNSET) {
|
||||||
startWindowIndex = getCurrentWindowIndex();
|
startIndex = getCurrentMediaItemIndex();
|
||||||
startPositionMs = getCurrentPosition();
|
startPositionMs = getCurrentPosition();
|
||||||
}
|
}
|
||||||
Timeline currentTimeline = getCurrentTimeline();
|
Timeline currentTimeline = getCurrentTimeline();
|
||||||
|
|
@ -1120,7 +1120,7 @@ public final class CastPlayer extends BasePlayer {
|
||||||
}
|
}
|
||||||
return remoteMediaClient.queueLoad(
|
return remoteMediaClient.queueLoad(
|
||||||
mediaQueueItems,
|
mediaQueueItems,
|
||||||
min(startWindowIndex, mediaQueueItems.length - 1),
|
min(startIndex, mediaQueueItems.length - 1),
|
||||||
getCastRepeatMode(repeatMode),
|
getCastRepeatMode(repeatMode),
|
||||||
startPositionMs,
|
startPositionMs,
|
||||||
/* customData= */ null);
|
/* customData= */ null);
|
||||||
|
|
@ -1180,7 +1180,7 @@ public final class CastPlayer extends BasePlayer {
|
||||||
}
|
}
|
||||||
return new PositionInfo(
|
return new PositionInfo(
|
||||||
newWindowUid,
|
newWindowUid,
|
||||||
getCurrentWindowIndex(),
|
getCurrentMediaItemIndex(),
|
||||||
newMediaItem,
|
newMediaItem,
|
||||||
newPeriodUid,
|
newPeriodUid,
|
||||||
getCurrentPeriodIndex(),
|
getCurrentPeriodIndex(),
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ import com.google.android.exoplayer2.util.Util;
|
||||||
timeline.getPeriod(0, period).getAdDurationUs(adGroupIndex, adIndexInAdGroup);
|
timeline.getPeriod(0, period).getAdDurationUs(adGroupIndex, adIndexInAdGroup);
|
||||||
return Util.usToMs(adDurationUs);
|
return Util.usToMs(adDurationUs);
|
||||||
} else {
|
} else {
|
||||||
return timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs();
|
return timeline.getWindow(getCurrentMediaItemIndex(), window).getDurationMs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab
|
||||||
if (player.getPlaybackState() == Player.STATE_IDLE) {
|
if (player.getPlaybackState() == Player.STATE_IDLE) {
|
||||||
player.prepare();
|
player.prepare();
|
||||||
} else if (player.getPlaybackState() == Player.STATE_ENDED) {
|
} else if (player.getPlaybackState() == Player.STATE_ENDED) {
|
||||||
player.seekToDefaultPosition(player.getCurrentWindowIndex());
|
player.seekToDefaultPosition(player.getCurrentMediaItemIndex());
|
||||||
}
|
}
|
||||||
if (player.isCommandAvailable(Player.COMMAND_PLAY_PAUSE)) {
|
if (player.isCommandAvailable(Player.COMMAND_PLAY_PAUSE)) {
|
||||||
player.play();
|
player.play();
|
||||||
|
|
|
||||||
|
|
@ -253,8 +253,8 @@ import java.util.List;
|
||||||
// checkIndex() throws IndexOutOfBoundsException which maps the RESULT_ERROR_BAD_VALUE
|
// checkIndex() throws IndexOutOfBoundsException which maps the RESULT_ERROR_BAD_VALUE
|
||||||
// but RESULT_ERROR_INVALID_STATE with IllegalStateException is expected here.
|
// but RESULT_ERROR_INVALID_STATE with IllegalStateException is expected here.
|
||||||
Assertions.checkState(0 <= index && index < timeline.getWindowCount());
|
Assertions.checkState(0 <= index && index < timeline.getWindowCount());
|
||||||
int windowIndex = player.getCurrentWindowIndex();
|
int currentIndex = player.getCurrentMediaItemIndex();
|
||||||
if (windowIndex == index || !player.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)) {
|
if (currentIndex == index || !player.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.seekToDefaultPosition(index);
|
player.seekToDefaultPosition(index);
|
||||||
|
|
@ -301,7 +301,7 @@ import java.util.List;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentMediaItemIndex() {
|
public int getCurrentMediaItemIndex() {
|
||||||
return media2Playlist.isEmpty() ? C.INDEX_UNSET : player.getCurrentWindowIndex();
|
return media2Playlist.isEmpty() ? C.INDEX_UNSET : player.getCurrentMediaItemIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPreviousMediaItemIndex() {
|
public int getPreviousMediaItemIndex() {
|
||||||
|
|
@ -331,7 +331,7 @@ import java.util.List;
|
||||||
if (!player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)) {
|
if (!player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.seekTo(player.getCurrentWindowIndex(), /* positionMs= */ 0);
|
player.seekTo(player.getCurrentMediaItemIndex(), /* positionMs= */ 0);
|
||||||
}
|
}
|
||||||
boolean playWhenReady = player.getPlayWhenReady();
|
boolean playWhenReady = player.getPlayWhenReady();
|
||||||
int suppressReason = player.getPlaybackSuppressionReason();
|
int suppressReason = player.getPlaybackSuppressionReason();
|
||||||
|
|
@ -358,7 +358,7 @@ import java.util.List;
|
||||||
if (!player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)) {
|
if (!player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.seekTo(player.getCurrentWindowIndex(), position);
|
player.seekTo(player.getCurrentMediaItemIndex(), position);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -493,7 +493,7 @@ import java.util.List;
|
||||||
public boolean isCurrentMediaItemSeekable() {
|
public boolean isCurrentMediaItemSeekable() {
|
||||||
return getCurrentMediaItem() != null
|
return getCurrentMediaItem() != null
|
||||||
&& !player.isPlayingAd()
|
&& !player.isPlayingAd()
|
||||||
&& player.isCurrentWindowSeekable();
|
&& player.isCurrentMediaItemSeekable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSkipToPlaylistItem() {
|
public boolean canSkipToPlaylistItem() {
|
||||||
|
|
@ -502,11 +502,11 @@ import java.util.List;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSkipToPreviousPlaylistItem() {
|
public boolean canSkipToPreviousPlaylistItem() {
|
||||||
return player.hasPreviousWindow();
|
return player.hasPreviousMediaItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSkipToNextPlaylistItem() {
|
public boolean canSkipToNextPlaylistItem() {
|
||||||
return player.hasNextWindow();
|
return player.hasNextMediaItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasError() {
|
public boolean hasError() {
|
||||||
|
|
|
||||||
|
|
@ -263,12 +263,13 @@ public final class MediaSessionConnector {
|
||||||
* @param player The player connected to the media session.
|
* @param player The player connected to the media session.
|
||||||
*/
|
*/
|
||||||
void onTimelineChanged(Player player);
|
void onTimelineChanged(Player player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the current window index changed.
|
* Called when the current media item index changed.
|
||||||
*
|
*
|
||||||
* @param player The player connected to the media session.
|
* @param player The player connected to the media session.
|
||||||
*/
|
*/
|
||||||
void onCurrentWindowIndexChanged(Player player);
|
default void onCurrentMediaItemIndexChanged(Player player) {}
|
||||||
/**
|
/**
|
||||||
* Gets the id of the currently active queue item, or {@link
|
* Gets the id of the currently active queue item, or {@link
|
||||||
* MediaSessionCompat.QueueItem#UNKNOWN_ID} if the active item is unknown.
|
* MediaSessionCompat.QueueItem#UNKNOWN_ID} if the active item is unknown.
|
||||||
|
|
@ -969,8 +970,8 @@ public final class MediaSessionConnector {
|
||||||
return player != null && mediaButtonEventHandler != null;
|
return player != null && mediaButtonEventHandler != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seekTo(Player player, int windowIndex, long positionMs) {
|
private void seekTo(Player player, int mediaItemIndex, long positionMs) {
|
||||||
player.seekTo(windowIndex, positionMs);
|
player.seekTo(mediaItemIndex, positionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getMediaSessionPlaybackState(
|
private static int getMediaSessionPlaybackState(
|
||||||
|
|
@ -1023,7 +1024,7 @@ public final class MediaSessionConnector {
|
||||||
}
|
}
|
||||||
builder.putLong(
|
builder.putLong(
|
||||||
MediaMetadataCompat.METADATA_KEY_DURATION,
|
MediaMetadataCompat.METADATA_KEY_DURATION,
|
||||||
player.isCurrentWindowDynamic() || player.getDuration() == C.TIME_UNSET
|
player.isCurrentMediaItemDynamic() || player.getDuration() == C.TIME_UNSET
|
||||||
? -1
|
? -1
|
||||||
: player.getDuration());
|
: player.getDuration());
|
||||||
long activeQueueItemId = mediaController.getPlaybackState().getActiveQueueItemId();
|
long activeQueueItemId = mediaController.getPlaybackState().getActiveQueueItemId();
|
||||||
|
|
@ -1097,7 +1098,7 @@ public final class MediaSessionConnector {
|
||||||
|
|
||||||
private class ComponentListener extends MediaSessionCompat.Callback implements Player.Listener {
|
private class ComponentListener extends MediaSessionCompat.Callback implements Player.Listener {
|
||||||
|
|
||||||
private int currentWindowIndex;
|
private int currentMediaItemIndex;
|
||||||
private int currentWindowCount;
|
private int currentWindowCount;
|
||||||
|
|
||||||
// Player.Listener implementation.
|
// Player.Listener implementation.
|
||||||
|
|
@ -1107,9 +1108,9 @@ public final class MediaSessionConnector {
|
||||||
boolean invalidatePlaybackState = false;
|
boolean invalidatePlaybackState = false;
|
||||||
boolean invalidateMetadata = false;
|
boolean invalidateMetadata = false;
|
||||||
if (events.contains(Player.EVENT_POSITION_DISCONTINUITY)) {
|
if (events.contains(Player.EVENT_POSITION_DISCONTINUITY)) {
|
||||||
if (currentWindowIndex != player.getCurrentWindowIndex()) {
|
if (currentMediaItemIndex != player.getCurrentMediaItemIndex()) {
|
||||||
if (queueNavigator != null) {
|
if (queueNavigator != null) {
|
||||||
queueNavigator.onCurrentWindowIndexChanged(player);
|
queueNavigator.onCurrentMediaItemIndexChanged(player);
|
||||||
}
|
}
|
||||||
invalidateMetadata = true;
|
invalidateMetadata = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1118,11 +1119,11 @@ public final class MediaSessionConnector {
|
||||||
|
|
||||||
if (events.contains(Player.EVENT_TIMELINE_CHANGED)) {
|
if (events.contains(Player.EVENT_TIMELINE_CHANGED)) {
|
||||||
int windowCount = player.getCurrentTimeline().getWindowCount();
|
int windowCount = player.getCurrentTimeline().getWindowCount();
|
||||||
int windowIndex = player.getCurrentWindowIndex();
|
int mediaItemIndex = player.getCurrentMediaItemIndex();
|
||||||
if (queueNavigator != null) {
|
if (queueNavigator != null) {
|
||||||
queueNavigator.onTimelineChanged(player);
|
queueNavigator.onTimelineChanged(player);
|
||||||
invalidatePlaybackState = true;
|
invalidatePlaybackState = true;
|
||||||
} else if (currentWindowCount != windowCount || currentWindowIndex != windowIndex) {
|
} else if (currentWindowCount != windowCount || currentMediaItemIndex != mediaItemIndex) {
|
||||||
// active queue item and queue navigation actions may need to be updated
|
// active queue item and queue navigation actions may need to be updated
|
||||||
invalidatePlaybackState = true;
|
invalidatePlaybackState = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1130,8 +1131,8 @@ public final class MediaSessionConnector {
|
||||||
invalidateMetadata = true;
|
invalidateMetadata = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update currentWindowIndex after comparisons above.
|
// Update currentMediaItemIndex after comparisons above.
|
||||||
currentWindowIndex = player.getCurrentWindowIndex();
|
currentMediaItemIndex = player.getCurrentMediaItemIndex();
|
||||||
|
|
||||||
if (events.containsAny(
|
if (events.containsAny(
|
||||||
EVENT_PLAYBACK_STATE_CHANGED,
|
EVENT_PLAYBACK_STATE_CHANGED,
|
||||||
|
|
@ -1170,7 +1171,7 @@ public final class MediaSessionConnector {
|
||||||
player.prepare();
|
player.prepare();
|
||||||
}
|
}
|
||||||
} else if (player.getPlaybackState() == Player.STATE_ENDED) {
|
} else if (player.getPlaybackState() == Player.STATE_ENDED) {
|
||||||
seekTo(player, player.getCurrentWindowIndex(), C.TIME_UNSET);
|
seekTo(player, player.getCurrentMediaItemIndex(), C.TIME_UNSET);
|
||||||
}
|
}
|
||||||
Assertions.checkNotNull(player).play();
|
Assertions.checkNotNull(player).play();
|
||||||
}
|
}
|
||||||
|
|
@ -1186,7 +1187,7 @@ public final class MediaSessionConnector {
|
||||||
@Override
|
@Override
|
||||||
public void onSeekTo(long positionMs) {
|
public void onSeekTo(long positionMs) {
|
||||||
if (canDispatchPlaybackAction(PlaybackStateCompat.ACTION_SEEK_TO)) {
|
if (canDispatchPlaybackAction(PlaybackStateCompat.ACTION_SEEK_TO)) {
|
||||||
seekTo(player, player.getCurrentWindowIndex(), positionMs);
|
seekTo(player, player.getCurrentMediaItemIndex(), positionMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ public abstract class TimelineQueueNavigator implements MediaSessionConnector.Qu
|
||||||
boolean enableNext = false;
|
boolean enableNext = false;
|
||||||
Timeline timeline = player.getCurrentTimeline();
|
Timeline timeline = player.getCurrentTimeline();
|
||||||
if (!timeline.isEmpty() && !player.isPlayingAd()) {
|
if (!timeline.isEmpty() && !player.isPlayingAd()) {
|
||||||
timeline.getWindow(player.getCurrentWindowIndex(), window);
|
timeline.getWindow(player.getCurrentMediaItemIndex(), window);
|
||||||
enableSkipTo = timeline.getWindowCount() > 1;
|
enableSkipTo = timeline.getWindowCount() > 1;
|
||||||
enablePrevious =
|
enablePrevious =
|
||||||
player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)
|
player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)
|
||||||
|
|
@ -128,12 +128,12 @@ public abstract class TimelineQueueNavigator implements MediaSessionConnector.Qu
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onCurrentWindowIndexChanged(Player player) {
|
public final void onCurrentMediaItemIndexChanged(Player player) {
|
||||||
if (activeQueueItemId == MediaSessionCompat.QueueItem.UNKNOWN_ID
|
if (activeQueueItemId == MediaSessionCompat.QueueItem.UNKNOWN_ID
|
||||||
|| player.getCurrentTimeline().getWindowCount() > maxQueueSize) {
|
|| player.getCurrentTimeline().getWindowCount() > maxQueueSize) {
|
||||||
publishFloatingQueueWindow(player);
|
publishFloatingQueueWindow(player);
|
||||||
} else if (!player.getCurrentTimeline().isEmpty()) {
|
} else if (!player.getCurrentTimeline().isEmpty()) {
|
||||||
activeQueueItemId = player.getCurrentWindowIndex();
|
activeQueueItemId = player.getCurrentMediaItemIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -185,40 +185,40 @@ public abstract class TimelineQueueNavigator implements MediaSessionConnector.Qu
|
||||||
int queueSize = min(maxQueueSize, timeline.getWindowCount());
|
int queueSize = min(maxQueueSize, timeline.getWindowCount());
|
||||||
|
|
||||||
// Add the active queue item.
|
// Add the active queue item.
|
||||||
int currentWindowIndex = player.getCurrentWindowIndex();
|
int currentMediaItemIndex = player.getCurrentMediaItemIndex();
|
||||||
queue.add(
|
queue.add(
|
||||||
new MediaSessionCompat.QueueItem(
|
new MediaSessionCompat.QueueItem(
|
||||||
getMediaDescription(player, currentWindowIndex), currentWindowIndex));
|
getMediaDescription(player, currentMediaItemIndex), currentMediaItemIndex));
|
||||||
|
|
||||||
// Fill queue alternating with next and/or previous queue items.
|
// Fill queue alternating with next and/or previous queue items.
|
||||||
int firstWindowIndex = currentWindowIndex;
|
int firstMediaItemIndex = currentMediaItemIndex;
|
||||||
int lastWindowIndex = currentWindowIndex;
|
int lastMediaItemIndex = currentMediaItemIndex;
|
||||||
boolean shuffleModeEnabled = player.getShuffleModeEnabled();
|
boolean shuffleModeEnabled = player.getShuffleModeEnabled();
|
||||||
while ((firstWindowIndex != C.INDEX_UNSET || lastWindowIndex != C.INDEX_UNSET)
|
while ((firstMediaItemIndex != C.INDEX_UNSET || lastMediaItemIndex != C.INDEX_UNSET)
|
||||||
&& queue.size() < queueSize) {
|
&& queue.size() < queueSize) {
|
||||||
// Begin with next to have a longer tail than head if an even sized queue needs to be trimmed.
|
// Begin with next to have a longer tail than head if an even sized queue needs to be trimmed.
|
||||||
if (lastWindowIndex != C.INDEX_UNSET) {
|
if (lastMediaItemIndex != C.INDEX_UNSET) {
|
||||||
lastWindowIndex =
|
lastMediaItemIndex =
|
||||||
timeline.getNextWindowIndex(
|
timeline.getNextWindowIndex(
|
||||||
lastWindowIndex, Player.REPEAT_MODE_OFF, shuffleModeEnabled);
|
lastMediaItemIndex, Player.REPEAT_MODE_OFF, shuffleModeEnabled);
|
||||||
if (lastWindowIndex != C.INDEX_UNSET) {
|
if (lastMediaItemIndex != C.INDEX_UNSET) {
|
||||||
queue.add(
|
queue.add(
|
||||||
new MediaSessionCompat.QueueItem(
|
new MediaSessionCompat.QueueItem(
|
||||||
getMediaDescription(player, lastWindowIndex), lastWindowIndex));
|
getMediaDescription(player, lastMediaItemIndex), lastMediaItemIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstWindowIndex != C.INDEX_UNSET && queue.size() < queueSize) {
|
if (firstMediaItemIndex != C.INDEX_UNSET && queue.size() < queueSize) {
|
||||||
firstWindowIndex =
|
firstMediaItemIndex =
|
||||||
timeline.getPreviousWindowIndex(
|
timeline.getPreviousWindowIndex(
|
||||||
firstWindowIndex, Player.REPEAT_MODE_OFF, shuffleModeEnabled);
|
firstMediaItemIndex, Player.REPEAT_MODE_OFF, shuffleModeEnabled);
|
||||||
if (firstWindowIndex != C.INDEX_UNSET) {
|
if (firstMediaItemIndex != C.INDEX_UNSET) {
|
||||||
queue.addFirst(
|
queue.addFirst(
|
||||||
new MediaSessionCompat.QueueItem(
|
new MediaSessionCompat.QueueItem(
|
||||||
getMediaDescription(player, firstWindowIndex), firstWindowIndex));
|
getMediaDescription(player, firstMediaItemIndex), firstMediaItemIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mediaSession.setQueue(new ArrayList<>(queue));
|
mediaSession.setQueue(new ArrayList<>(queue));
|
||||||
activeQueueItemId = currentWindowIndex;
|
activeQueueItemId = currentMediaItemIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ public abstract class BasePlayer implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void seekToDefaultPosition() {
|
public final void seekToDefaultPosition() {
|
||||||
seekToDefaultPosition(getCurrentWindowIndex());
|
seekToDefaultPosition(getCurrentMediaItemIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -128,7 +128,7 @@ public abstract class BasePlayer implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void seekTo(long positionMs) {
|
public final void seekTo(long positionMs) {
|
||||||
seekTo(getCurrentWindowIndex(), positionMs);
|
seekTo(getCurrentMediaItemIndex(), positionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -184,13 +184,13 @@ public abstract class BasePlayer implements Player {
|
||||||
if (timeline.isEmpty() || isPlayingAd()) {
|
if (timeline.isEmpty() || isPlayingAd()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean hasPreviousWindow = hasPreviousWindow();
|
boolean hasPreviousMediaItem = hasPreviousMediaItem();
|
||||||
if (isCurrentWindowLive() && !isCurrentWindowSeekable()) {
|
if (isCurrentMediaItemLive() && !isCurrentMediaItemSeekable()) {
|
||||||
if (hasPreviousWindow) {
|
if (hasPreviousMediaItem) {
|
||||||
seekToPreviousWindow();
|
seekToPreviousMediaItem();
|
||||||
}
|
}
|
||||||
} else if (hasPreviousWindow && getCurrentPosition() <= getMaxSeekToPreviousPosition()) {
|
} else if (hasPreviousMediaItem && getCurrentPosition() <= getMaxSeekToPreviousPosition()) {
|
||||||
seekToPreviousWindow();
|
seekToPreviousMediaItem();
|
||||||
} else {
|
} else {
|
||||||
seekTo(/* positionMs= */ 0);
|
seekTo(/* positionMs= */ 0);
|
||||||
}
|
}
|
||||||
|
|
@ -239,9 +239,9 @@ public abstract class BasePlayer implements Player {
|
||||||
if (timeline.isEmpty() || isPlayingAd()) {
|
if (timeline.isEmpty() || isPlayingAd()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasNextWindow()) {
|
if (hasNextMediaItem()) {
|
||||||
seekToNextWindow();
|
seekToNextMediaItem();
|
||||||
} else if (isCurrentWindowLive() && isCurrentWindowDynamic()) {
|
} else if (isCurrentMediaItemLive() && isCurrentMediaItemDynamic()) {
|
||||||
seekToDefaultPosition();
|
seekToDefaultPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -293,7 +293,7 @@ public abstract class BasePlayer implements Player {
|
||||||
Timeline timeline = getCurrentTimeline();
|
Timeline timeline = getCurrentTimeline();
|
||||||
return timeline.isEmpty()
|
return timeline.isEmpty()
|
||||||
? null
|
? null
|
||||||
: timeline.getWindow(getCurrentWindowIndex(), window).mediaItem;
|
: timeline.getWindow(getCurrentMediaItemIndex(), window).mediaItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -310,7 +310,9 @@ public abstract class BasePlayer implements Player {
|
||||||
@Nullable
|
@Nullable
|
||||||
public final Object getCurrentManifest() {
|
public final Object getCurrentManifest() {
|
||||||
Timeline timeline = getCurrentTimeline();
|
Timeline timeline = getCurrentTimeline();
|
||||||
return timeline.isEmpty() ? null : timeline.getWindow(getCurrentWindowIndex(), window).manifest;
|
return timeline.isEmpty()
|
||||||
|
? null
|
||||||
|
: timeline.getWindow(getCurrentMediaItemIndex(), window).manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -352,7 +354,8 @@ public abstract class BasePlayer implements Player {
|
||||||
if (timeline.isEmpty()) {
|
if (timeline.isEmpty()) {
|
||||||
return C.TIME_UNSET;
|
return C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
long windowStartTimeMs = timeline.getWindow(getCurrentWindowIndex(), window).windowStartTimeMs;
|
long windowStartTimeMs =
|
||||||
|
timeline.getWindow(getCurrentMediaItemIndex(), window).windowStartTimeMs;
|
||||||
if (windowStartTimeMs == C.TIME_UNSET) {
|
if (windowStartTimeMs == C.TIME_UNSET) {
|
||||||
return C.TIME_UNSET;
|
return C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
|
@ -376,7 +379,7 @@ public abstract class BasePlayer implements Player {
|
||||||
Timeline timeline = getCurrentTimeline();
|
Timeline timeline = getCurrentTimeline();
|
||||||
return timeline.isEmpty()
|
return timeline.isEmpty()
|
||||||
? C.TIME_UNSET
|
? C.TIME_UNSET
|
||||||
: timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs();
|
: timeline.getWindow(getCurrentMediaItemIndex(), window).getDurationMs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -389,22 +392,24 @@ public abstract class BasePlayer implements Player {
|
||||||
return new Commands.Builder()
|
return new Commands.Builder()
|
||||||
.addAll(permanentAvailableCommands)
|
.addAll(permanentAvailableCommands)
|
||||||
.addIf(COMMAND_SEEK_TO_DEFAULT_POSITION, !isPlayingAd())
|
.addIf(COMMAND_SEEK_TO_DEFAULT_POSITION, !isPlayingAd())
|
||||||
.addIf(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, isCurrentWindowSeekable() && !isPlayingAd())
|
.addIf(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, isCurrentMediaItemSeekable() && !isPlayingAd())
|
||||||
.addIf(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, hasPreviousWindow() && !isPlayingAd())
|
.addIf(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, hasPreviousMediaItem() && !isPlayingAd())
|
||||||
.addIf(
|
.addIf(
|
||||||
COMMAND_SEEK_TO_PREVIOUS,
|
COMMAND_SEEK_TO_PREVIOUS,
|
||||||
!getCurrentTimeline().isEmpty()
|
!getCurrentTimeline().isEmpty()
|
||||||
&& (hasPreviousWindow() || !isCurrentWindowLive() || isCurrentWindowSeekable())
|
&& (hasPreviousMediaItem()
|
||||||
|
|| !isCurrentMediaItemLive()
|
||||||
|
|| isCurrentMediaItemSeekable())
|
||||||
&& !isPlayingAd())
|
&& !isPlayingAd())
|
||||||
.addIf(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, hasNextWindow() && !isPlayingAd())
|
.addIf(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, hasNextMediaItem() && !isPlayingAd())
|
||||||
.addIf(
|
.addIf(
|
||||||
COMMAND_SEEK_TO_NEXT,
|
COMMAND_SEEK_TO_NEXT,
|
||||||
!getCurrentTimeline().isEmpty()
|
!getCurrentTimeline().isEmpty()
|
||||||
&& (hasNextWindow() || (isCurrentWindowLive() && isCurrentWindowDynamic()))
|
&& (hasNextMediaItem() || (isCurrentMediaItemLive() && isCurrentMediaItemDynamic()))
|
||||||
&& !isPlayingAd())
|
&& !isPlayingAd())
|
||||||
.addIf(COMMAND_SEEK_TO_MEDIA_ITEM, !isPlayingAd())
|
.addIf(COMMAND_SEEK_TO_MEDIA_ITEM, !isPlayingAd())
|
||||||
.addIf(COMMAND_SEEK_BACK, isCurrentWindowSeekable() && !isPlayingAd())
|
.addIf(COMMAND_SEEK_BACK, isCurrentMediaItemSeekable() && !isPlayingAd())
|
||||||
.addIf(COMMAND_SEEK_FORWARD, isCurrentWindowSeekable() && !isPlayingAd())
|
.addIf(COMMAND_SEEK_FORWARD, isCurrentMediaItemSeekable() && !isPlayingAd())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1126,7 +1126,7 @@ public interface ExoPlayer extends Player {
|
||||||
* @param mediaSources The new {@link MediaSource MediaSources}.
|
* @param mediaSources The new {@link MediaSource MediaSources}.
|
||||||
* @param resetPosition Whether the playback position should be reset to the default position in
|
* @param resetPosition Whether the playback position should be reset to the default position in
|
||||||
* the first {@link Timeline.Window}. If false, playback will start from the position defined
|
* the first {@link Timeline.Window}. If false, playback will start from the position defined
|
||||||
* by {@link #getCurrentWindowIndex()} and {@link #getCurrentPosition()}.
|
* by {@link #getCurrentMediaItemIndex()} and {@link #getCurrentPosition()}.
|
||||||
*/
|
*/
|
||||||
void setMediaSources(List<MediaSource> mediaSources, boolean resetPosition);
|
void setMediaSources(List<MediaSource> mediaSources, boolean resetPosition);
|
||||||
|
|
||||||
|
|
@ -1134,14 +1134,15 @@ public interface ExoPlayer extends Player {
|
||||||
* Clears the playlist and adds the specified {@link MediaSource MediaSources}.
|
* Clears the playlist and adds the specified {@link MediaSource MediaSources}.
|
||||||
*
|
*
|
||||||
* @param mediaSources The new {@link MediaSource MediaSources}.
|
* @param mediaSources The new {@link MediaSource MediaSources}.
|
||||||
* @param startWindowIndex The window index to start playback from. If {@link C#INDEX_UNSET} is
|
* @param startMediaItemIndex The media item index to start playback from. If {@link
|
||||||
* passed, the current position is not reset.
|
* C#INDEX_UNSET} is passed, the current position is not reset.
|
||||||
* @param startPositionMs The position in milliseconds to start playback from. If {@link
|
* @param startPositionMs The position in milliseconds to start playback from. If {@link
|
||||||
* C#TIME_UNSET} is passed, the default position of the given window is used. In any case, if
|
* C#TIME_UNSET} is passed, the default position of the given media item is used. In any case,
|
||||||
* {@code startWindowIndex} is set to {@link C#INDEX_UNSET}, this parameter is ignored and the
|
* if {@code startMediaItemIndex} is set to {@link C#INDEX_UNSET}, this parameter is ignored
|
||||||
* position is not reset at all.
|
* and the position is not reset at all.
|
||||||
*/
|
*/
|
||||||
void setMediaSources(List<MediaSource> mediaSources, int startWindowIndex, long startPositionMs);
|
void setMediaSources(
|
||||||
|
List<MediaSource> mediaSources, int startMediaItemIndex, long startPositionMs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the playlist, adds the specified {@link MediaSource} and resets the position to the
|
* Clears the playlist, adds the specified {@link MediaSource} and resets the position to the
|
||||||
|
|
@ -1164,7 +1165,7 @@ public interface ExoPlayer extends Player {
|
||||||
*
|
*
|
||||||
* @param mediaSource The new {@link MediaSource}.
|
* @param mediaSource The new {@link MediaSource}.
|
||||||
* @param resetPosition Whether the playback position should be reset to the default position. If
|
* @param resetPosition Whether the playback position should be reset to the default position. If
|
||||||
* false, playback will start from the position defined by {@link #getCurrentWindowIndex()}
|
* false, playback will start from the position defined by {@link #getCurrentMediaItemIndex()}
|
||||||
* and {@link #getCurrentPosition()}.
|
* and {@link #getCurrentPosition()}.
|
||||||
*/
|
*/
|
||||||
void setMediaSource(MediaSource mediaSource, boolean resetPosition);
|
void setMediaSource(MediaSource mediaSource, boolean resetPosition);
|
||||||
|
|
@ -1331,9 +1332,9 @@ public interface ExoPlayer extends Player {
|
||||||
* will be delivered immediately without blocking on the playback thread. The default {@link
|
* will be delivered immediately without blocking on the playback thread. The default {@link
|
||||||
* PlayerMessage#getType()} is 0 and the default {@link PlayerMessage#getPayload()} is null. If a
|
* PlayerMessage#getType()} is 0 and the default {@link PlayerMessage#getPayload()} is null. If a
|
||||||
* position is specified with {@link PlayerMessage#setPosition(long)}, the message will be
|
* position is specified with {@link PlayerMessage#setPosition(long)}, the message will be
|
||||||
* delivered at this position in the current window defined by {@link #getCurrentWindowIndex()}.
|
* delivered at this position in the current media item defined by {@link
|
||||||
* Alternatively, the message can be sent at a specific window using {@link
|
* #getCurrentMediaItemIndex()}. Alternatively, the message can be sent at a specific mediaItem
|
||||||
* PlayerMessage#setPosition(int, long)}.
|
* using {@link PlayerMessage#setPosition(int, long)}.
|
||||||
*/
|
*/
|
||||||
PlayerMessage createMessage(PlayerMessage.Target target);
|
PlayerMessage createMessage(PlayerMessage.Target target);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -537,7 +537,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
playbackInfo,
|
playbackInfo,
|
||||||
timeline,
|
timeline,
|
||||||
getPeriodPositionOrMaskWindowPosition(
|
getPeriodPositionOrMaskWindowPosition(
|
||||||
timeline, getCurrentWindowIndex(), getCurrentPosition()));
|
timeline, getCurrentMediaItemIndex(), getCurrentPosition()));
|
||||||
pendingOperationAcks++;
|
pendingOperationAcks++;
|
||||||
this.shuffleOrder = shuffleOrder;
|
this.shuffleOrder = shuffleOrder;
|
||||||
internalPlayer.setShuffleOrder(shuffleOrder);
|
internalPlayer.setShuffleOrder(shuffleOrder);
|
||||||
|
|
@ -662,7 +662,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
@Player.State
|
@Player.State
|
||||||
int newPlaybackState =
|
int newPlaybackState =
|
||||||
getPlaybackState() == Player.STATE_IDLE ? Player.STATE_IDLE : Player.STATE_BUFFERING;
|
getPlaybackState() == Player.STATE_IDLE ? Player.STATE_IDLE : Player.STATE_BUFFERING;
|
||||||
int oldMaskingWindowIndex = getCurrentWindowIndex();
|
int oldMaskingMediaItemIndex = getCurrentMediaItemIndex();
|
||||||
PlaybackInfo newPlaybackInfo = playbackInfo.copyWithPlaybackState(newPlaybackState);
|
PlaybackInfo newPlaybackInfo = playbackInfo.copyWithPlaybackState(newPlaybackState);
|
||||||
newPlaybackInfo =
|
newPlaybackInfo =
|
||||||
maskTimelineAndPosition(
|
maskTimelineAndPosition(
|
||||||
|
|
@ -678,7 +678,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
/* positionDiscontinuity= */ true,
|
/* positionDiscontinuity= */ true,
|
||||||
/* positionDiscontinuityReason= */ DISCONTINUITY_REASON_SEEK,
|
/* positionDiscontinuityReason= */ DISCONTINUITY_REASON_SEEK,
|
||||||
/* discontinuityWindowStartPositionUs= */ getCurrentPositionUsInternal(newPlaybackInfo),
|
/* discontinuityWindowStartPositionUs= */ getCurrentPositionUsInternal(newPlaybackInfo),
|
||||||
oldMaskingWindowIndex);
|
oldMaskingMediaItemIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -839,7 +839,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
internalPlayer,
|
internalPlayer,
|
||||||
target,
|
target,
|
||||||
playbackInfo.timeline,
|
playbackInfo.timeline,
|
||||||
getCurrentWindowIndex(),
|
getCurrentMediaItemIndex(),
|
||||||
clock,
|
clock,
|
||||||
internalPlayer.getPlaybackLooper());
|
internalPlayer.getPlaybackLooper());
|
||||||
}
|
}
|
||||||
|
|
@ -910,7 +910,10 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
if (isPlayingAd()) {
|
if (isPlayingAd()) {
|
||||||
playbackInfo.timeline.getPeriodByUid(playbackInfo.periodId.periodUid, period);
|
playbackInfo.timeline.getPeriodByUid(playbackInfo.periodId.periodUid, period);
|
||||||
return playbackInfo.requestedContentPositionUs == C.TIME_UNSET
|
return playbackInfo.requestedContentPositionUs == C.TIME_UNSET
|
||||||
? playbackInfo.timeline.getWindow(getCurrentWindowIndex(), window).getDefaultPositionMs()
|
? playbackInfo
|
||||||
|
.timeline
|
||||||
|
.getWindow(getCurrentMediaItemIndex(), window)
|
||||||
|
.getDefaultPositionMs()
|
||||||
: period.getPositionInWindowMs() + Util.usToMs(playbackInfo.requestedContentPositionUs);
|
: period.getPositionInWindowMs() + Util.usToMs(playbackInfo.requestedContentPositionUs);
|
||||||
} else {
|
} else {
|
||||||
return getCurrentPosition();
|
return getCurrentPosition();
|
||||||
|
|
@ -924,7 +927,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
}
|
}
|
||||||
if (playbackInfo.loadingMediaPeriodId.windowSequenceNumber
|
if (playbackInfo.loadingMediaPeriodId.windowSequenceNumber
|
||||||
!= playbackInfo.periodId.windowSequenceNumber) {
|
!= playbackInfo.periodId.windowSequenceNumber) {
|
||||||
return playbackInfo.timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs();
|
return playbackInfo.timeline.getWindow(getCurrentMediaItemIndex(), window).getDurationMs();
|
||||||
}
|
}
|
||||||
long contentBufferedPositionUs = playbackInfo.bufferedPositionUs;
|
long contentBufferedPositionUs = playbackInfo.bufferedPositionUs;
|
||||||
if (playbackInfo.loadingMediaPeriodId.isAd()) {
|
if (playbackInfo.loadingMediaPeriodId.isAd()) {
|
||||||
|
|
@ -1218,7 +1221,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
boolean positionDiscontinuity,
|
boolean positionDiscontinuity,
|
||||||
@DiscontinuityReason int positionDiscontinuityReason,
|
@DiscontinuityReason int positionDiscontinuityReason,
|
||||||
long discontinuityWindowStartPositionUs,
|
long discontinuityWindowStartPositionUs,
|
||||||
int oldMaskingWindowIndex) {
|
int oldMaskingMediaItemIndex) {
|
||||||
|
|
||||||
// Assign playback info immediately such that all getters return the right values, but keep
|
// Assign playback info immediately such that all getters return the right values, but keep
|
||||||
// snapshot of previous and new state so that listener invocations are triggered correctly.
|
// snapshot of previous and new state so that listener invocations are triggered correctly.
|
||||||
|
|
@ -1267,7 +1270,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
if (positionDiscontinuity) {
|
if (positionDiscontinuity) {
|
||||||
PositionInfo previousPositionInfo =
|
PositionInfo previousPositionInfo =
|
||||||
getPreviousPositionInfo(
|
getPreviousPositionInfo(
|
||||||
positionDiscontinuityReason, previousPlaybackInfo, oldMaskingWindowIndex);
|
positionDiscontinuityReason, previousPlaybackInfo, oldMaskingMediaItemIndex);
|
||||||
PositionInfo positionInfo = getPositionInfo(discontinuityWindowStartPositionUs);
|
PositionInfo positionInfo = getPositionInfo(discontinuityWindowStartPositionUs);
|
||||||
listeners.queueEvent(
|
listeners.queueEvent(
|
||||||
Player.EVENT_POSITION_DISCONTINUITY,
|
Player.EVENT_POSITION_DISCONTINUITY,
|
||||||
|
|
@ -1378,19 +1381,19 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
private PositionInfo getPreviousPositionInfo(
|
private PositionInfo getPreviousPositionInfo(
|
||||||
@DiscontinuityReason int positionDiscontinuityReason,
|
@DiscontinuityReason int positionDiscontinuityReason,
|
||||||
PlaybackInfo oldPlaybackInfo,
|
PlaybackInfo oldPlaybackInfo,
|
||||||
int oldMaskingWindowIndex) {
|
int oldMaskingMediaItemIndex) {
|
||||||
@Nullable Object oldWindowUid = null;
|
@Nullable Object oldWindowUid = null;
|
||||||
@Nullable Object oldPeriodUid = null;
|
@Nullable Object oldPeriodUid = null;
|
||||||
int oldWindowIndex = oldMaskingWindowIndex;
|
int oldMediaItemIndex = oldMaskingMediaItemIndex;
|
||||||
int oldPeriodIndex = C.INDEX_UNSET;
|
int oldPeriodIndex = C.INDEX_UNSET;
|
||||||
@Nullable MediaItem oldMediaItem = null;
|
@Nullable MediaItem oldMediaItem = null;
|
||||||
Timeline.Period oldPeriod = new Timeline.Period();
|
Timeline.Period oldPeriod = new Timeline.Period();
|
||||||
if (!oldPlaybackInfo.timeline.isEmpty()) {
|
if (!oldPlaybackInfo.timeline.isEmpty()) {
|
||||||
oldPeriodUid = oldPlaybackInfo.periodId.periodUid;
|
oldPeriodUid = oldPlaybackInfo.periodId.periodUid;
|
||||||
oldPlaybackInfo.timeline.getPeriodByUid(oldPeriodUid, oldPeriod);
|
oldPlaybackInfo.timeline.getPeriodByUid(oldPeriodUid, oldPeriod);
|
||||||
oldWindowIndex = oldPeriod.windowIndex;
|
oldMediaItemIndex = oldPeriod.windowIndex;
|
||||||
oldPeriodIndex = oldPlaybackInfo.timeline.getIndexOfPeriod(oldPeriodUid);
|
oldPeriodIndex = oldPlaybackInfo.timeline.getIndexOfPeriod(oldPeriodUid);
|
||||||
oldWindowUid = oldPlaybackInfo.timeline.getWindow(oldWindowIndex, window).uid;
|
oldWindowUid = oldPlaybackInfo.timeline.getWindow(oldMediaItemIndex, window).uid;
|
||||||
oldMediaItem = window.mediaItem;
|
oldMediaItem = window.mediaItem;
|
||||||
}
|
}
|
||||||
long oldPositionUs;
|
long oldPositionUs;
|
||||||
|
|
@ -1421,7 +1424,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
}
|
}
|
||||||
return new PositionInfo(
|
return new PositionInfo(
|
||||||
oldWindowUid,
|
oldWindowUid,
|
||||||
oldWindowIndex,
|
oldMediaItemIndex,
|
||||||
oldMediaItem,
|
oldMediaItem,
|
||||||
oldPeriodUid,
|
oldPeriodUid,
|
||||||
oldPeriodIndex,
|
oldPeriodIndex,
|
||||||
|
|
@ -1434,20 +1437,20 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
private PositionInfo getPositionInfo(long discontinuityWindowStartPositionUs) {
|
private PositionInfo getPositionInfo(long discontinuityWindowStartPositionUs) {
|
||||||
@Nullable Object newWindowUid = null;
|
@Nullable Object newWindowUid = null;
|
||||||
@Nullable Object newPeriodUid = null;
|
@Nullable Object newPeriodUid = null;
|
||||||
int newWindowIndex = getCurrentWindowIndex();
|
int newMediaItemIndex = getCurrentMediaItemIndex();
|
||||||
int newPeriodIndex = C.INDEX_UNSET;
|
int newPeriodIndex = C.INDEX_UNSET;
|
||||||
@Nullable MediaItem newMediaItem = null;
|
@Nullable MediaItem newMediaItem = null;
|
||||||
if (!playbackInfo.timeline.isEmpty()) {
|
if (!playbackInfo.timeline.isEmpty()) {
|
||||||
newPeriodUid = playbackInfo.periodId.periodUid;
|
newPeriodUid = playbackInfo.periodId.periodUid;
|
||||||
playbackInfo.timeline.getPeriodByUid(newPeriodUid, period);
|
playbackInfo.timeline.getPeriodByUid(newPeriodUid, period);
|
||||||
newPeriodIndex = playbackInfo.timeline.getIndexOfPeriod(newPeriodUid);
|
newPeriodIndex = playbackInfo.timeline.getIndexOfPeriod(newPeriodUid);
|
||||||
newWindowUid = playbackInfo.timeline.getWindow(newWindowIndex, window).uid;
|
newWindowUid = playbackInfo.timeline.getWindow(newMediaItemIndex, window).uid;
|
||||||
newMediaItem = window.mediaItem;
|
newMediaItem = window.mediaItem;
|
||||||
}
|
}
|
||||||
long positionMs = Util.usToMs(discontinuityWindowStartPositionUs);
|
long positionMs = Util.usToMs(discontinuityWindowStartPositionUs);
|
||||||
return new PositionInfo(
|
return new PositionInfo(
|
||||||
newWindowUid,
|
newWindowUid,
|
||||||
newWindowIndex,
|
newMediaItemIndex,
|
||||||
newMediaItem,
|
newMediaItem,
|
||||||
newPeriodUid,
|
newPeriodUid,
|
||||||
newPeriodIndex,
|
newPeriodIndex,
|
||||||
|
|
@ -1601,7 +1604,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
private PlaybackInfo removeMediaItemsInternal(int fromIndex, int toIndex) {
|
private PlaybackInfo removeMediaItemsInternal(int fromIndex, int toIndex) {
|
||||||
Assertions.checkArgument(
|
Assertions.checkArgument(
|
||||||
fromIndex >= 0 && toIndex >= fromIndex && toIndex <= mediaSourceHolderSnapshots.size());
|
fromIndex >= 0 && toIndex >= fromIndex && toIndex <= mediaSourceHolderSnapshots.size());
|
||||||
int currentWindowIndex = getCurrentWindowIndex();
|
int currentIndex = getCurrentMediaItemIndex();
|
||||||
Timeline oldTimeline = getCurrentTimeline();
|
Timeline oldTimeline = getCurrentTimeline();
|
||||||
int currentMediaSourceCount = mediaSourceHolderSnapshots.size();
|
int currentMediaSourceCount = mediaSourceHolderSnapshots.size();
|
||||||
pendingOperationAcks++;
|
pendingOperationAcks++;
|
||||||
|
|
@ -1618,7 +1621,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
&& newPlaybackInfo.playbackState != STATE_ENDED
|
&& newPlaybackInfo.playbackState != STATE_ENDED
|
||||||
&& fromIndex < toIndex
|
&& fromIndex < toIndex
|
||||||
&& toIndex == currentMediaSourceCount
|
&& toIndex == currentMediaSourceCount
|
||||||
&& currentWindowIndex >= newPlaybackInfo.timeline.getWindowCount();
|
&& currentIndex >= newPlaybackInfo.timeline.getWindowCount();
|
||||||
if (transitionsToEnded) {
|
if (transitionsToEnded) {
|
||||||
newPlaybackInfo = newPlaybackInfo.copyWithPlaybackState(STATE_ENDED);
|
newPlaybackInfo = newPlaybackInfo.copyWithPlaybackState(STATE_ENDED);
|
||||||
}
|
}
|
||||||
|
|
@ -1753,11 +1756,11 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
isCleared ? C.INDEX_UNSET : getCurrentWindowIndexInternal(),
|
isCleared ? C.INDEX_UNSET : getCurrentWindowIndexInternal(),
|
||||||
isCleared ? C.TIME_UNSET : currentPositionMs);
|
isCleared ? C.TIME_UNSET : currentPositionMs);
|
||||||
}
|
}
|
||||||
int currentWindowIndex = getCurrentWindowIndex();
|
int currentMediaItemIndex = getCurrentMediaItemIndex();
|
||||||
@Nullable
|
@Nullable
|
||||||
Pair<Object, Long> oldPeriodPosition =
|
Pair<Object, Long> oldPeriodPosition =
|
||||||
oldTimeline.getPeriodPosition(
|
oldTimeline.getPeriodPosition(
|
||||||
window, period, currentWindowIndex, Util.msToUs(currentPositionMs));
|
window, period, currentMediaItemIndex, Util.msToUs(currentPositionMs));
|
||||||
Object periodUid = castNonNull(oldPeriodPosition).first;
|
Object periodUid = castNonNull(oldPeriodPosition).first;
|
||||||
if (newTimeline.getIndexOfPeriod(periodUid) != C.INDEX_UNSET) {
|
if (newTimeline.getIndexOfPeriod(periodUid) != C.INDEX_UNSET) {
|
||||||
// The old period position is still available in the new timeline.
|
// The old period position is still available in the new timeline.
|
||||||
|
|
|
||||||
|
|
@ -2718,7 +2718,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
newTimeline,
|
newTimeline,
|
||||||
new SeekPosition(
|
new SeekPosition(
|
||||||
pendingMessageInfo.message.getTimeline(),
|
pendingMessageInfo.message.getTimeline(),
|
||||||
pendingMessageInfo.message.getWindowIndex(),
|
pendingMessageInfo.message.getMediaItemIndex(),
|
||||||
requestPositionUs),
|
requestPositionUs),
|
||||||
/* trySubsequentPeriods= */ false,
|
/* trySubsequentPeriods= */ false,
|
||||||
repeatMode,
|
repeatMode,
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public final class PlayerMessage {
|
||||||
private int type;
|
private int type;
|
||||||
@Nullable private Object payload;
|
@Nullable private Object payload;
|
||||||
private Looper looper;
|
private Looper looper;
|
||||||
private int windowIndex;
|
private int mediaItemIndex;
|
||||||
private long positionMs;
|
private long positionMs;
|
||||||
private boolean deleteAfterDelivery;
|
private boolean deleteAfterDelivery;
|
||||||
private boolean isSent;
|
private boolean isSent;
|
||||||
|
|
@ -78,8 +78,8 @@ public final class PlayerMessage {
|
||||||
* @param target The {@link Target} the message is sent to.
|
* @param target The {@link Target} the message is sent to.
|
||||||
* @param timeline The timeline used when setting the position with {@link #setPosition(long)}. If
|
* @param timeline The timeline used when setting the position with {@link #setPosition(long)}. If
|
||||||
* set to {@link Timeline#EMPTY}, any position can be specified.
|
* set to {@link Timeline#EMPTY}, any position can be specified.
|
||||||
* @param defaultWindowIndex The default window index in the {@code timeline} when no other window
|
* @param defaultMediaItemIndex The default media item index in the {@code timeline} when no other
|
||||||
* index is specified.
|
* media item index is specified.
|
||||||
* @param clock The {@link Clock}.
|
* @param clock The {@link Clock}.
|
||||||
* @param defaultLooper The default {@link Looper} to send the message on when no other looper is
|
* @param defaultLooper The default {@link Looper} to send the message on when no other looper is
|
||||||
* specified.
|
* specified.
|
||||||
|
|
@ -88,7 +88,7 @@ public final class PlayerMessage {
|
||||||
Sender sender,
|
Sender sender,
|
||||||
Target target,
|
Target target,
|
||||||
Timeline timeline,
|
Timeline timeline,
|
||||||
int defaultWindowIndex,
|
int defaultMediaItemIndex,
|
||||||
Clock clock,
|
Clock clock,
|
||||||
Looper defaultLooper) {
|
Looper defaultLooper) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
|
|
@ -96,7 +96,7 @@ public final class PlayerMessage {
|
||||||
this.timeline = timeline;
|
this.timeline = timeline;
|
||||||
this.looper = defaultLooper;
|
this.looper = defaultLooper;
|
||||||
this.clock = clock;
|
this.clock = clock;
|
||||||
this.windowIndex = defaultWindowIndex;
|
this.mediaItemIndex = defaultMediaItemIndex;
|
||||||
this.positionMs = C.TIME_UNSET;
|
this.positionMs = C.TIME_UNSET;
|
||||||
this.deleteAfterDelivery = true;
|
this.deleteAfterDelivery = true;
|
||||||
}
|
}
|
||||||
|
|
@ -173,21 +173,21 @@ public final class PlayerMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns position in window at {@link #getWindowIndex()} at which the message will be delivered,
|
* Returns position in the media item at {@link #getMediaItemIndex()} at which the message will be
|
||||||
* in milliseconds. If {@link C#TIME_UNSET}, the message will be delivered immediately. If {@link
|
* delivered, in milliseconds. If {@link C#TIME_UNSET}, the message will be delivered immediately.
|
||||||
* C#TIME_END_OF_SOURCE}, the message will be delivered at the end of the window at {@link
|
* If {@link C#TIME_END_OF_SOURCE}, the message will be delivered at the end of the media item at
|
||||||
* #getWindowIndex()}.
|
* {@link #getMediaItemIndex()}.
|
||||||
*/
|
*/
|
||||||
public long getPositionMs() {
|
public long getPositionMs() {
|
||||||
return positionMs;
|
return positionMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a position in the current window at which the message will be delivered.
|
* Sets a position in the current media item at which the message will be delivered.
|
||||||
*
|
*
|
||||||
* @param positionMs The position in the current window at which the message will be sent, in
|
* @param positionMs The position in the current media item at which the message will be sent, in
|
||||||
* milliseconds, or {@link C#TIME_END_OF_SOURCE} to deliver the message at the end of the
|
* milliseconds, or {@link C#TIME_END_OF_SOURCE} to deliver the message at the end of the
|
||||||
* current window.
|
* current media item.
|
||||||
* @return This message.
|
* @return This message.
|
||||||
* @throws IllegalStateException If {@link #send()} has already been called.
|
* @throws IllegalStateException If {@link #send()} has already been called.
|
||||||
*/
|
*/
|
||||||
|
|
@ -198,31 +198,32 @@ public final class PlayerMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a position in a window at which the message will be delivered.
|
* Sets a position in a media item at which the message will be delivered.
|
||||||
*
|
*
|
||||||
* @param windowIndex The index of the window at which the message will be sent.
|
* @param mediaItemIndex The index of the media item at which the message will be sent.
|
||||||
* @param positionMs The position in the window with index {@code windowIndex} at which the
|
* @param positionMs The position in the media item with index {@code mediaItemIndex} at which the
|
||||||
* message will be sent, in milliseconds, or {@link C#TIME_END_OF_SOURCE} to deliver the
|
* message will be sent, in milliseconds, or {@link C#TIME_END_OF_SOURCE} to deliver the
|
||||||
* message at the end of the window with index {@code windowIndex}.
|
* message at the end of the media item with index {@code mediaItemIndex}.
|
||||||
* @return This message.
|
* @return This message.
|
||||||
* @throws IllegalSeekPositionException If the timeline returned by {@link #getTimeline()} is not
|
* @throws IllegalSeekPositionException If the timeline returned by {@link #getTimeline()} is not
|
||||||
* empty and the provided window index is not within the bounds of the timeline.
|
* empty and the provided media item index is not within the bounds of the timeline.
|
||||||
* @throws IllegalStateException If {@link #send()} has already been called.
|
* @throws IllegalStateException If {@link #send()} has already been called.
|
||||||
*/
|
*/
|
||||||
public PlayerMessage setPosition(int windowIndex, long positionMs) {
|
public PlayerMessage setPosition(int mediaItemIndex, long positionMs) {
|
||||||
Assertions.checkState(!isSent);
|
Assertions.checkState(!isSent);
|
||||||
Assertions.checkArgument(positionMs != C.TIME_UNSET);
|
Assertions.checkArgument(positionMs != C.TIME_UNSET);
|
||||||
if (windowIndex < 0 || (!timeline.isEmpty() && windowIndex >= timeline.getWindowCount())) {
|
if (mediaItemIndex < 0
|
||||||
throw new IllegalSeekPositionException(timeline, windowIndex, positionMs);
|
|| (!timeline.isEmpty() && mediaItemIndex >= timeline.getWindowCount())) {
|
||||||
|
throw new IllegalSeekPositionException(timeline, mediaItemIndex, positionMs);
|
||||||
}
|
}
|
||||||
this.windowIndex = windowIndex;
|
this.mediaItemIndex = mediaItemIndex;
|
||||||
this.positionMs = positionMs;
|
this.positionMs = positionMs;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns window index at which the message will be delivered. */
|
/** Returns media item index at which the message will be delivered. */
|
||||||
public int getWindowIndex() {
|
public int getMediaItemIndex() {
|
||||||
return windowIndex;
|
return mediaItemIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1110,9 +1110,9 @@ public class SimpleExoPlayer extends BasePlayer
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMediaSources(
|
public void setMediaSources(
|
||||||
List<MediaSource> mediaSources, int startWindowIndex, long startPositionMs) {
|
List<MediaSource> mediaSources, int startMediaItemIndex, long startPositionMs) {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
player.setMediaSources(mediaSources, startWindowIndex, startPositionMs);
|
player.setMediaSources(mediaSources, startMediaItemIndex, startPositionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1419,7 +1419,7 @@ public class SimpleExoPlayer extends BasePlayer
|
||||||
@Override
|
@Override
|
||||||
public int getCurrentMediaItemIndex() {
|
public int getCurrentMediaItemIndex() {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
return player.getCurrentWindowIndex();
|
return player.getCurrentMediaItemIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -914,7 +914,7 @@ public class AnalyticsCollector
|
||||||
long eventPositionMs;
|
long eventPositionMs;
|
||||||
boolean isInCurrentWindow =
|
boolean isInCurrentWindow =
|
||||||
timeline.equals(player.getCurrentTimeline())
|
timeline.equals(player.getCurrentTimeline())
|
||||||
&& windowIndex == player.getCurrentWindowIndex();
|
&& windowIndex == player.getCurrentMediaItemIndex();
|
||||||
if (mediaPeriodId != null && mediaPeriodId.isAd()) {
|
if (mediaPeriodId != null && mediaPeriodId.isAd()) {
|
||||||
boolean isCurrentAd =
|
boolean isCurrentAd =
|
||||||
isInCurrentWindow
|
isInCurrentWindow
|
||||||
|
|
@ -939,7 +939,7 @@ public class AnalyticsCollector
|
||||||
mediaPeriodId,
|
mediaPeriodId,
|
||||||
eventPositionMs,
|
eventPositionMs,
|
||||||
player.getCurrentTimeline(),
|
player.getCurrentTimeline(),
|
||||||
player.getCurrentWindowIndex(),
|
player.getCurrentMediaItemIndex(),
|
||||||
currentMediaPeriodId,
|
currentMediaPeriodId,
|
||||||
player.getCurrentPosition(),
|
player.getCurrentPosition(),
|
||||||
player.getTotalBufferedDuration());
|
player.getTotalBufferedDuration());
|
||||||
|
|
@ -962,7 +962,7 @@ public class AnalyticsCollector
|
||||||
? null
|
? null
|
||||||
: mediaPeriodQueueTracker.getMediaPeriodIdTimeline(mediaPeriodId);
|
: mediaPeriodQueueTracker.getMediaPeriodIdTimeline(mediaPeriodId);
|
||||||
if (mediaPeriodId == null || knownTimeline == null) {
|
if (mediaPeriodId == null || knownTimeline == null) {
|
||||||
int windowIndex = player.getCurrentWindowIndex();
|
int windowIndex = player.getCurrentMediaItemIndex();
|
||||||
Timeline timeline = player.getCurrentTimeline();
|
Timeline timeline = player.getCurrentTimeline();
|
||||||
boolean windowIsInTimeline = windowIndex < timeline.getWindowCount();
|
boolean windowIsInTimeline = windowIndex < timeline.getWindowCount();
|
||||||
return generateEventTime(
|
return generateEventTime(
|
||||||
|
|
|
||||||
|
|
@ -382,7 +382,7 @@ public interface AnalyticsListener {
|
||||||
/**
|
/**
|
||||||
* The current window index in {@link #currentTimeline} at the time of the event, or the
|
* The current window index in {@link #currentTimeline} at the time of the event, or the
|
||||||
* prospective window index if the timeline is not yet known and empty (equivalent to {@link
|
* prospective window index if the timeline is not yet known and empty (equivalent to {@link
|
||||||
* Player#getCurrentWindowIndex()}).
|
* Player#getCurrentMediaItemIndex()}).
|
||||||
*/
|
*/
|
||||||
public final int currentWindowIndex;
|
public final int currentWindowIndex;
|
||||||
|
|
||||||
|
|
@ -419,7 +419,7 @@ public interface AnalyticsListener {
|
||||||
* {@link Player#getCurrentTimeline()}).
|
* {@link Player#getCurrentTimeline()}).
|
||||||
* @param currentWindowIndex The current window index in {@code currentTimeline} at the time of
|
* @param currentWindowIndex The current window index in {@code currentTimeline} at the time of
|
||||||
* the event, or the prospective window index if the timeline is not yet known and empty
|
* the event, or the prospective window index if the timeline is not yet known and empty
|
||||||
* (equivalent to {@link Player#getCurrentWindowIndex()}).
|
* (equivalent to {@link Player#getCurrentMediaItemIndex()}).
|
||||||
* @param currentMediaPeriodId {@link MediaPeriodId Media period identifier} for the currently
|
* @param currentMediaPeriodId {@link MediaPeriodId Media period identifier} for the currently
|
||||||
* playing media period at the time of the event, or {@code null} if no current media period
|
* playing media period at the time of the event, or {@code null} if no current media period
|
||||||
* identifier is available.
|
* identifier is available.
|
||||||
|
|
@ -1204,9 +1204,9 @@ public interface AnalyticsListener {
|
||||||
* {@link Player#seekTo(long)} after a {@link
|
* {@link Player#seekTo(long)} after a {@link
|
||||||
* AnalyticsListener#onMediaItemTransition(EventTime, MediaItem, int)}).
|
* AnalyticsListener#onMediaItemTransition(EventTime, MediaItem, int)}).
|
||||||
* <li>They intend to use multiple state values together or in combination with {@link Player}
|
* <li>They intend to use multiple state values together or in combination with {@link Player}
|
||||||
* getter methods. For example using {@link Player#getCurrentWindowIndex()} with the {@code
|
* getter methods. For example using {@link Player#getCurrentMediaItemIndex()} with the
|
||||||
* timeline} provided in {@link #onTimelineChanged(EventTime, int)} is only safe from within
|
* {@code timeline} provided in {@link #onTimelineChanged(EventTime, int)} is only safe from
|
||||||
* this method.
|
* within this method.
|
||||||
* <li>They are interested in events that logically happened together (e.g {@link
|
* <li>They are interested in events that logically happened together (e.g {@link
|
||||||
* #onPlaybackStateChanged(EventTime, int)} to {@link Player#STATE_BUFFERING} because of
|
* #onPlaybackStateChanged(EventTime, int)} to {@link Player#STATE_BUFFERING} because of
|
||||||
* {@link #onMediaItemTransition(EventTime, MediaItem, int)}).
|
* {@link #onMediaItemTransition(EventTime, MediaItem, int)}).
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,8 @@ public final class FrameworkMediaDrm implements ExoMediaDrm {
|
||||||
mediaDrm.closeSession(sessionId);
|
mediaDrm.closeSession(sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return values of MediaDrm.KeyRequest.getRequestType are equal to KeyRequest.RequestType.
|
||||||
|
@SuppressLint("WrongConstant")
|
||||||
@Override
|
@Override
|
||||||
public KeyRequest getKeyRequest(
|
public KeyRequest getKeyRequest(
|
||||||
byte[] scope,
|
byte[] scope,
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,8 @@ import com.google.android.exoplayer2.util.NetworkTypeObserver;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import com.google.common.base.Ascii;
|
import com.google.common.base.Ascii;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableListMultimap;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,13 +40,6 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public final class DefaultBandwidthMeter implements BandwidthMeter, TransferListener {
|
public final class DefaultBandwidthMeter implements BandwidthMeter, TransferListener {
|
||||||
|
|
||||||
/**
|
|
||||||
* Country groups used to determine the default initial bitrate estimate. The group assignment for
|
|
||||||
* each country is a list for [Wifi, 2G, 3G, 4G, 5G_NSA, 5G_SA].
|
|
||||||
*/
|
|
||||||
public static final ImmutableListMultimap<String, Integer>
|
|
||||||
DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS = createInitialBitrateCountryGroupAssignment();
|
|
||||||
|
|
||||||
/** Default initial Wifi bitrate estimate in bits per second. */
|
/** Default initial Wifi bitrate estimate in bits per second. */
|
||||||
public static final ImmutableList<Long> DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI =
|
public static final ImmutableList<Long> DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI =
|
||||||
ImmutableList.of(5_400_000L, 3_300_000L, 2_000_000L, 1_300_000L, 760_000L);
|
ImmutableList.of(5_400_000L, 3_300_000L, 2_000_000L, 1_300_000L, 760_000L);
|
||||||
|
|
@ -82,17 +73,35 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
|
||||||
/** Default maximum weight for the sliding window. */
|
/** Default maximum weight for the sliding window. */
|
||||||
public static final int DEFAULT_SLIDING_WINDOW_MAX_WEIGHT = 2000;
|
public static final int DEFAULT_SLIDING_WINDOW_MAX_WEIGHT = 2000;
|
||||||
|
|
||||||
/** Index for the Wifi group index in {@link #DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS}. */
|
/**
|
||||||
|
* Index for the Wifi group index in the array returned by {@link
|
||||||
|
* #getInitialBitrateCountryGroupAssignment}.
|
||||||
|
*/
|
||||||
private static final int COUNTRY_GROUP_INDEX_WIFI = 0;
|
private static final int COUNTRY_GROUP_INDEX_WIFI = 0;
|
||||||
/** Index for the 2G group index in {@link #DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS}. */
|
/**
|
||||||
|
* Index for the 2G group index in the array returned by {@link
|
||||||
|
* #getInitialBitrateCountryGroupAssignment}.
|
||||||
|
*/
|
||||||
private static final int COUNTRY_GROUP_INDEX_2G = 1;
|
private static final int COUNTRY_GROUP_INDEX_2G = 1;
|
||||||
/** Index for the 3G group index in {@link #DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS}. */
|
/**
|
||||||
|
* Index for the 3G group index in the array returned by {@link
|
||||||
|
* #getInitialBitrateCountryGroupAssignment}.
|
||||||
|
*/
|
||||||
private static final int COUNTRY_GROUP_INDEX_3G = 2;
|
private static final int COUNTRY_GROUP_INDEX_3G = 2;
|
||||||
/** Index for the 4G group index in {@link #DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS}. */
|
/**
|
||||||
|
* Index for the 4G group index in the array returned by {@link
|
||||||
|
* #getInitialBitrateCountryGroupAssignment}.
|
||||||
|
*/
|
||||||
private static final int COUNTRY_GROUP_INDEX_4G = 3;
|
private static final int COUNTRY_GROUP_INDEX_4G = 3;
|
||||||
/** Index for the 5G-NSA group index in {@link #DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS}. */
|
/**
|
||||||
|
* Index for the 5G-NSA group index in the array returned by {@link
|
||||||
|
* #getInitialBitrateCountryGroupAssignment}.
|
||||||
|
*/
|
||||||
private static final int COUNTRY_GROUP_INDEX_5G_NSA = 4;
|
private static final int COUNTRY_GROUP_INDEX_5G_NSA = 4;
|
||||||
/** Index for the 5G-SA group index in {@link #DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS}. */
|
/**
|
||||||
|
* Index for the 5G-SA group index in the array returned by {@link
|
||||||
|
* #getInitialBitrateCountryGroupAssignment}.
|
||||||
|
*/
|
||||||
private static final int COUNTRY_GROUP_INDEX_5G_SA = 5;
|
private static final int COUNTRY_GROUP_INDEX_5G_SA = 5;
|
||||||
|
|
||||||
@Nullable private static DefaultBandwidthMeter singletonInstance;
|
@Nullable private static DefaultBandwidthMeter singletonInstance;
|
||||||
|
|
@ -212,40 +221,33 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Integer, Long> getInitialBitrateEstimatesForCountry(String countryCode) {
|
private static Map<Integer, Long> getInitialBitrateEstimatesForCountry(String countryCode) {
|
||||||
List<Integer> groupIndices = getCountryGroupIndices(countryCode);
|
int[] groupIndices = getInitialBitrateCountryGroupAssignment(countryCode);
|
||||||
Map<Integer, Long> result = new HashMap<>(/* initialCapacity= */ 8);
|
Map<Integer, Long> result = new HashMap<>(/* initialCapacity= */ 8);
|
||||||
result.put(C.NETWORK_TYPE_UNKNOWN, DEFAULT_INITIAL_BITRATE_ESTIMATE);
|
result.put(C.NETWORK_TYPE_UNKNOWN, DEFAULT_INITIAL_BITRATE_ESTIMATE);
|
||||||
result.put(
|
result.put(
|
||||||
C.NETWORK_TYPE_WIFI,
|
C.NETWORK_TYPE_WIFI,
|
||||||
DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI.get(groupIndices.get(COUNTRY_GROUP_INDEX_WIFI)));
|
DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI.get(groupIndices[COUNTRY_GROUP_INDEX_WIFI]));
|
||||||
result.put(
|
result.put(
|
||||||
C.NETWORK_TYPE_2G,
|
C.NETWORK_TYPE_2G,
|
||||||
DEFAULT_INITIAL_BITRATE_ESTIMATES_2G.get(groupIndices.get(COUNTRY_GROUP_INDEX_2G)));
|
DEFAULT_INITIAL_BITRATE_ESTIMATES_2G.get(groupIndices[COUNTRY_GROUP_INDEX_2G]));
|
||||||
result.put(
|
result.put(
|
||||||
C.NETWORK_TYPE_3G,
|
C.NETWORK_TYPE_3G,
|
||||||
DEFAULT_INITIAL_BITRATE_ESTIMATES_3G.get(groupIndices.get(COUNTRY_GROUP_INDEX_3G)));
|
DEFAULT_INITIAL_BITRATE_ESTIMATES_3G.get(groupIndices[COUNTRY_GROUP_INDEX_3G]));
|
||||||
result.put(
|
result.put(
|
||||||
C.NETWORK_TYPE_4G,
|
C.NETWORK_TYPE_4G,
|
||||||
DEFAULT_INITIAL_BITRATE_ESTIMATES_4G.get(groupIndices.get(COUNTRY_GROUP_INDEX_4G)));
|
DEFAULT_INITIAL_BITRATE_ESTIMATES_4G.get(groupIndices[COUNTRY_GROUP_INDEX_4G]));
|
||||||
result.put(
|
result.put(
|
||||||
C.NETWORK_TYPE_5G_NSA,
|
C.NETWORK_TYPE_5G_NSA,
|
||||||
DEFAULT_INITIAL_BITRATE_ESTIMATES_5G_NSA.get(
|
DEFAULT_INITIAL_BITRATE_ESTIMATES_5G_NSA.get(groupIndices[COUNTRY_GROUP_INDEX_5G_NSA]));
|
||||||
groupIndices.get(COUNTRY_GROUP_INDEX_5G_NSA)));
|
|
||||||
result.put(
|
result.put(
|
||||||
C.NETWORK_TYPE_5G_SA,
|
C.NETWORK_TYPE_5G_SA,
|
||||||
DEFAULT_INITIAL_BITRATE_ESTIMATES_5G_SA.get(groupIndices.get(COUNTRY_GROUP_INDEX_5G_SA)));
|
DEFAULT_INITIAL_BITRATE_ESTIMATES_5G_SA.get(groupIndices[COUNTRY_GROUP_INDEX_5G_SA]));
|
||||||
// Assume default Wifi speed for Ethernet to prevent using the slower fallback.
|
// Assume default Wifi speed for Ethernet to prevent using the slower fallback.
|
||||||
result.put(
|
result.put(
|
||||||
C.NETWORK_TYPE_ETHERNET,
|
C.NETWORK_TYPE_ETHERNET,
|
||||||
DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI.get(groupIndices.get(COUNTRY_GROUP_INDEX_WIFI)));
|
DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI.get(groupIndices[COUNTRY_GROUP_INDEX_WIFI]));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ImmutableList<Integer> getCountryGroupIndices(String countryCode) {
|
|
||||||
ImmutableList<Integer> groupIndices = DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS.get(countryCode);
|
|
||||||
// Assume median group if not found.
|
|
||||||
return groupIndices.isEmpty() ? ImmutableList.of(2, 2, 2, 2, 2, 2) : groupIndices;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -461,250 +463,411 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
|
||||||
return isNetwork && !dataSpec.isFlagSet(DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED);
|
return isNetwork && !dataSpec.isFlagSet(DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ImmutableListMultimap<String, Integer>
|
/**
|
||||||
createInitialBitrateCountryGroupAssignment() {
|
* Returns initial bitrate group assignments for a {@code country}. The initial bitrate is a list
|
||||||
return ImmutableListMultimap.<String, Integer>builder()
|
* of indexes for [Wifi, 2G, 3G, 4G, 5G_NSA, 5G_SA].
|
||||||
.putAll("AD", 1, 2, 0, 0, 2, 2)
|
*/
|
||||||
.putAll("AE", 1, 4, 4, 4, 3, 2)
|
private static int[] getInitialBitrateCountryGroupAssignment(String country) {
|
||||||
.putAll("AF", 4, 4, 4, 4, 2, 2)
|
switch (country) {
|
||||||
.putAll("AG", 2, 3, 1, 2, 2, 2)
|
case "AE":
|
||||||
.putAll("AI", 1, 2, 2, 2, 2, 2)
|
return new int[] {1, 4, 4, 4, 3, 2};
|
||||||
.putAll("AL", 1, 2, 0, 1, 2, 2)
|
case "AG":
|
||||||
.putAll("AM", 2, 3, 2, 4, 2, 2)
|
return new int[] {2, 3, 1, 2, 2, 2};
|
||||||
.putAll("AO", 3, 4, 3, 2, 2, 2)
|
case "AM":
|
||||||
.putAll("AQ", 4, 2, 2, 2, 2, 2)
|
return new int[] {2, 3, 2, 4, 2, 2};
|
||||||
.putAll("AR", 2, 4, 1, 1, 2, 2)
|
case "AR":
|
||||||
.putAll("AS", 2, 2, 2, 3, 2, 2)
|
return new int[] {2, 4, 1, 1, 2, 2};
|
||||||
.putAll("AT", 0, 0, 0, 0, 0, 2)
|
case "AS":
|
||||||
.putAll("AU", 0, 1, 0, 1, 2, 2)
|
return new int[] {2, 2, 2, 3, 2, 2};
|
||||||
.putAll("AW", 1, 2, 4, 4, 2, 2)
|
case "AU":
|
||||||
.putAll("AX", 0, 2, 2, 2, 2, 2)
|
return new int[] {0, 1, 0, 1, 2, 2};
|
||||||
.putAll("AZ", 3, 2, 4, 4, 2, 2)
|
case "BE":
|
||||||
.putAll("BA", 1, 2, 0, 1, 2, 2)
|
return new int[] {0, 0, 3, 3, 2, 2};
|
||||||
.putAll("BB", 0, 2, 0, 0, 2, 2)
|
case "BF":
|
||||||
.putAll("BD", 2, 1, 3, 3, 2, 2)
|
return new int[] {4, 3, 4, 3, 2, 2};
|
||||||
.putAll("BE", 0, 0, 3, 3, 2, 2)
|
case "BH":
|
||||||
.putAll("BF", 4, 3, 4, 3, 2, 2)
|
return new int[] {1, 2, 2, 4, 4, 2};
|
||||||
.putAll("BG", 0, 0, 0, 0, 1, 2)
|
case "BJ":
|
||||||
.putAll("BH", 1, 2, 2, 4, 4, 2)
|
return new int[] {4, 4, 3, 4, 2, 2};
|
||||||
.putAll("BI", 4, 3, 4, 4, 2, 2)
|
case "BN":
|
||||||
.putAll("BJ", 4, 4, 3, 4, 2, 2)
|
return new int[] {3, 2, 1, 1, 2, 2};
|
||||||
.putAll("BL", 1, 2, 2, 2, 2, 2)
|
case "BO":
|
||||||
.putAll("BM", 1, 2, 0, 0, 2, 2)
|
return new int[] {1, 3, 3, 2, 2, 2};
|
||||||
.putAll("BN", 3, 2, 1, 1, 2, 2)
|
case "BQ":
|
||||||
.putAll("BO", 1, 3, 3, 2, 2, 2)
|
return new int[] {1, 2, 2, 0, 2, 2};
|
||||||
.putAll("BQ", 1, 2, 2, 0, 2, 2)
|
case "BS":
|
||||||
.putAll("BR", 2, 3, 2, 2, 2, 2)
|
return new int[] {4, 2, 2, 3, 2, 2};
|
||||||
.putAll("BS", 4, 2, 2, 3, 2, 2)
|
case "BT":
|
||||||
.putAll("BT", 3, 1, 3, 2, 2, 2)
|
return new int[] {3, 1, 3, 2, 2, 2};
|
||||||
.putAll("BW", 3, 4, 1, 0, 2, 2)
|
case "BY":
|
||||||
.putAll("BY", 0, 1, 1, 3, 2, 2)
|
return new int[] {0, 1, 1, 3, 2, 2};
|
||||||
.putAll("BZ", 2, 4, 2, 2, 2, 2)
|
case "BZ":
|
||||||
.putAll("CA", 0, 2, 1, 2, 4, 1)
|
return new int[] {2, 4, 2, 2, 2, 2};
|
||||||
.putAll("CD", 4, 2, 3, 1, 2, 2)
|
case "CA":
|
||||||
.putAll("CF", 4, 2, 3, 2, 2, 2)
|
return new int[] {0, 2, 1, 2, 4, 1};
|
||||||
.putAll("CG", 2, 4, 3, 4, 2, 2)
|
case "CD":
|
||||||
.putAll("CH", 0, 0, 0, 0, 0, 2)
|
return new int[] {4, 2, 3, 1, 2, 2};
|
||||||
.putAll("CI", 3, 3, 3, 4, 2, 2)
|
case "CF":
|
||||||
.putAll("CK", 2, 2, 2, 1, 2, 2)
|
return new int[] {4, 2, 3, 2, 2, 2};
|
||||||
.putAll("CL", 1, 1, 2, 2, 3, 2)
|
case "CI":
|
||||||
.putAll("CM", 3, 4, 3, 2, 2, 2)
|
return new int[] {3, 3, 3, 4, 2, 2};
|
||||||
.putAll("CN", 2, 0, 2, 2, 3, 1)
|
case "CK":
|
||||||
.putAll("CO", 2, 2, 4, 2, 2, 2)
|
return new int[] {2, 2, 2, 1, 2, 2};
|
||||||
.putAll("CR", 2, 2, 4, 4, 2, 2)
|
case "AO":
|
||||||
.putAll("CU", 4, 4, 3, 2, 2, 2)
|
case "CM":
|
||||||
.putAll("CV", 2, 3, 1, 0, 2, 2)
|
return new int[] {3, 4, 3, 2, 2, 2};
|
||||||
.putAll("CW", 2, 2, 0, 0, 2, 2)
|
case "CN":
|
||||||
.putAll("CX", 1, 2, 2, 2, 2, 2)
|
return new int[] {2, 0, 2, 2, 3, 1};
|
||||||
.putAll("CY", 1, 0, 0, 0, 1, 2)
|
case "CO":
|
||||||
.putAll("CZ", 0, 0, 0, 0, 1, 2)
|
return new int[] {2, 2, 4, 2, 2, 2};
|
||||||
.putAll("DE", 0, 0, 2, 2, 1, 2)
|
case "CR":
|
||||||
.putAll("DJ", 4, 1, 4, 4, 2, 2)
|
return new int[] {2, 2, 4, 4, 2, 2};
|
||||||
.putAll("DK", 0, 0, 1, 0, 0, 2)
|
case "CV":
|
||||||
.putAll("DM", 1, 2, 2, 2, 2, 2)
|
return new int[] {2, 3, 1, 0, 2, 2};
|
||||||
.putAll("DO", 3, 4, 4, 4, 2, 2)
|
case "CW":
|
||||||
.putAll("DZ", 4, 3, 4, 4, 2, 2)
|
return new int[] {2, 2, 0, 0, 2, 2};
|
||||||
.putAll("EC", 2, 4, 2, 1, 2, 2)
|
case "CY":
|
||||||
.putAll("EE", 0, 0, 0, 0, 2, 2)
|
return new int[] {1, 0, 0, 0, 1, 2};
|
||||||
.putAll("EG", 3, 4, 2, 3, 2, 2)
|
case "DE":
|
||||||
.putAll("EH", 2, 2, 2, 2, 2, 2)
|
return new int[] {0, 0, 2, 2, 1, 2};
|
||||||
.putAll("ER", 4, 2, 2, 2, 2, 2)
|
case "DJ":
|
||||||
.putAll("ES", 0, 1, 1, 1, 2, 2)
|
return new int[] {4, 1, 4, 4, 2, 2};
|
||||||
.putAll("ET", 4, 4, 3, 1, 2, 2)
|
case "DK":
|
||||||
.putAll("FI", 0, 0, 0, 1, 0, 2)
|
return new int[] {0, 0, 1, 0, 0, 2};
|
||||||
.putAll("FJ", 3, 1, 3, 3, 2, 2)
|
case "EC":
|
||||||
.putAll("FK", 3, 2, 2, 2, 2, 2)
|
return new int[] {2, 4, 2, 1, 2, 2};
|
||||||
.putAll("FM", 3, 2, 4, 2, 2, 2)
|
case "EG":
|
||||||
.putAll("FO", 0, 2, 0, 0, 2, 2)
|
return new int[] {3, 4, 2, 3, 2, 2};
|
||||||
.putAll("FR", 1, 1, 2, 1, 1, 1)
|
case "ET":
|
||||||
.putAll("GA", 2, 3, 1, 1, 2, 2)
|
return new int[] {4, 4, 3, 1, 2, 2};
|
||||||
.putAll("GB", 0, 0, 1, 1, 2, 3)
|
case "FI":
|
||||||
.putAll("GD", 1, 2, 2, 2, 2, 2)
|
return new int[] {0, 0, 0, 1, 0, 2};
|
||||||
.putAll("GE", 1, 1, 1, 3, 2, 2)
|
case "FJ":
|
||||||
.putAll("GF", 2, 1, 2, 3, 2, 2)
|
return new int[] {3, 1, 3, 3, 2, 2};
|
||||||
.putAll("GG", 0, 2, 0, 0, 2, 2)
|
case "FM":
|
||||||
.putAll("GH", 3, 2, 3, 2, 2, 2)
|
return new int[] {3, 2, 4, 2, 2, 2};
|
||||||
.putAll("GI", 0, 2, 2, 2, 2, 2)
|
case "FR":
|
||||||
.putAll("GL", 1, 2, 0, 0, 2, 2)
|
return new int[] {1, 1, 2, 1, 1, 1};
|
||||||
.putAll("GM", 4, 2, 2, 4, 2, 2)
|
case "GA":
|
||||||
.putAll("GN", 4, 3, 4, 2, 2, 2)
|
return new int[] {2, 3, 1, 1, 2, 2};
|
||||||
.putAll("GP", 2, 1, 2, 3, 2, 2)
|
case "GB":
|
||||||
.putAll("GQ", 4, 2, 3, 4, 2, 2)
|
return new int[] {0, 0, 1, 1, 2, 3};
|
||||||
.putAll("GR", 1, 0, 0, 0, 2, 2)
|
case "GE":
|
||||||
.putAll("GT", 2, 3, 2, 1, 2, 2)
|
return new int[] {1, 1, 1, 3, 2, 2};
|
||||||
.putAll("GU", 1, 2, 4, 4, 2, 2)
|
case "BB":
|
||||||
.putAll("GW", 3, 4, 3, 3, 2, 2)
|
case "FO":
|
||||||
.putAll("GY", 3, 4, 1, 0, 2, 2)
|
case "GG":
|
||||||
.putAll("HK", 0, 1, 2, 3, 2, 0)
|
return new int[] {0, 2, 0, 0, 2, 2};
|
||||||
.putAll("HN", 3, 2, 3, 3, 2, 2)
|
case "GH":
|
||||||
.putAll("HR", 1, 0, 0, 0, 2, 2)
|
return new int[] {3, 2, 3, 2, 2, 2};
|
||||||
.putAll("HT", 4, 4, 4, 4, 2, 2)
|
case "GN":
|
||||||
.putAll("HU", 0, 0, 0, 1, 3, 2)
|
return new int[] {4, 3, 4, 2, 2, 2};
|
||||||
.putAll("ID", 3, 2, 3, 3, 3, 2)
|
case "GQ":
|
||||||
.putAll("IE", 0, 1, 1, 1, 2, 2)
|
return new int[] {4, 2, 3, 4, 2, 2};
|
||||||
.putAll("IL", 1, 1, 2, 3, 4, 2)
|
case "GT":
|
||||||
.putAll("IM", 0, 2, 0, 1, 2, 2)
|
return new int[] {2, 3, 2, 1, 2, 2};
|
||||||
.putAll("IN", 1, 1, 3, 2, 4, 3)
|
case "AW":
|
||||||
.putAll("IO", 4, 2, 2, 2, 2, 2)
|
case "GU":
|
||||||
.putAll("IQ", 3, 3, 3, 3, 2, 2)
|
return new int[] {1, 2, 4, 4, 2, 2};
|
||||||
.putAll("IR", 3, 0, 1, 1, 3, 0)
|
case "BW":
|
||||||
.putAll("IS", 0, 0, 0, 0, 0, 2)
|
case "GY":
|
||||||
.putAll("IT", 0, 1, 0, 1, 1, 2)
|
return new int[] {3, 4, 1, 0, 2, 2};
|
||||||
.putAll("JE", 3, 2, 1, 2, 2, 2)
|
case "HK":
|
||||||
.putAll("JM", 3, 4, 4, 4, 2, 2)
|
return new int[] {0, 1, 2, 3, 2, 0};
|
||||||
.putAll("JO", 1, 0, 0, 1, 2, 2)
|
case "HU":
|
||||||
.putAll("JP", 0, 1, 0, 1, 1, 1)
|
return new int[] {0, 0, 0, 1, 3, 2};
|
||||||
.putAll("KE", 3, 3, 2, 2, 2, 2)
|
case "ID":
|
||||||
.putAll("KG", 2, 1, 1, 1, 2, 2)
|
return new int[] {3, 2, 3, 3, 3, 2};
|
||||||
.putAll("KH", 1, 1, 4, 2, 2, 2)
|
case "ES":
|
||||||
.putAll("KI", 4, 2, 4, 3, 2, 2)
|
case "IE":
|
||||||
.putAll("KM", 4, 2, 4, 3, 2, 2)
|
return new int[] {0, 1, 1, 1, 2, 2};
|
||||||
.putAll("KN", 2, 2, 2, 2, 2, 2)
|
case "IL":
|
||||||
.putAll("KP", 3, 2, 2, 2, 2, 2)
|
return new int[] {1, 1, 2, 3, 4, 2};
|
||||||
.putAll("KR", 0, 0, 1, 3, 4, 4)
|
case "IM":
|
||||||
.putAll("KW", 1, 1, 0, 0, 0, 2)
|
return new int[] {0, 2, 0, 1, 2, 2};
|
||||||
.putAll("KY", 1, 2, 0, 1, 2, 2)
|
case "IN":
|
||||||
.putAll("KZ", 1, 1, 2, 2, 2, 2)
|
return new int[] {1, 1, 3, 2, 4, 3};
|
||||||
.putAll("LA", 2, 2, 1, 2, 2, 2)
|
case "IR":
|
||||||
.putAll("LB", 3, 2, 1, 4, 2, 2)
|
return new int[] {3, 0, 1, 1, 3, 0};
|
||||||
.putAll("LC", 1, 2, 0, 0, 2, 2)
|
case "IT":
|
||||||
.putAll("LI", 0, 2, 2, 2, 2, 2)
|
return new int[] {0, 1, 0, 1, 1, 2};
|
||||||
.putAll("LK", 3, 1, 3, 4, 4, 2)
|
case "JE":
|
||||||
.putAll("LR", 3, 4, 4, 3, 2, 2)
|
return new int[] {3, 2, 1, 2, 2, 2};
|
||||||
.putAll("LS", 3, 3, 4, 3, 2, 2)
|
case "DO":
|
||||||
.putAll("LT", 0, 0, 0, 0, 2, 2)
|
case "JM":
|
||||||
.putAll("LU", 1, 0, 2, 2, 2, 2)
|
return new int[] {3, 4, 4, 4, 2, 2};
|
||||||
.putAll("LV", 0, 0, 0, 0, 2, 2)
|
case "JP":
|
||||||
.putAll("LY", 4, 2, 4, 3, 2, 2)
|
return new int[] {0, 1, 0, 1, 1, 1};
|
||||||
.putAll("MA", 3, 2, 2, 2, 2, 2)
|
case "KE":
|
||||||
.putAll("MC", 0, 2, 2, 0, 2, 2)
|
return new int[] {3, 3, 2, 2, 2, 2};
|
||||||
.putAll("MD", 1, 0, 0, 0, 2, 2)
|
case "KG":
|
||||||
.putAll("ME", 1, 0, 0, 1, 2, 2)
|
return new int[] {2, 1, 1, 1, 2, 2};
|
||||||
.putAll("MF", 1, 2, 1, 0, 2, 2)
|
case "KH":
|
||||||
.putAll("MG", 3, 4, 2, 2, 2, 2)
|
return new int[] {1, 1, 4, 2, 2, 2};
|
||||||
.putAll("MH", 3, 2, 2, 4, 2, 2)
|
case "KR":
|
||||||
.putAll("MK", 1, 0, 0, 0, 2, 2)
|
return new int[] {0, 0, 1, 3, 4, 4};
|
||||||
.putAll("ML", 4, 3, 3, 1, 2, 2)
|
case "KW":
|
||||||
.putAll("MM", 2, 4, 3, 3, 2, 2)
|
return new int[] {1, 1, 0, 0, 0, 2};
|
||||||
.putAll("MN", 2, 0, 1, 2, 2, 2)
|
case "AL":
|
||||||
.putAll("MO", 0, 2, 4, 4, 2, 2)
|
case "BA":
|
||||||
.putAll("MP", 0, 2, 2, 2, 2, 2)
|
case "KY":
|
||||||
.putAll("MQ", 2, 1, 2, 3, 2, 2)
|
return new int[] {1, 2, 0, 1, 2, 2};
|
||||||
.putAll("MR", 4, 1, 3, 4, 2, 2)
|
case "KZ":
|
||||||
.putAll("MS", 1, 2, 2, 2, 2, 2)
|
return new int[] {1, 1, 2, 2, 2, 2};
|
||||||
.putAll("MT", 0, 0, 0, 0, 2, 2)
|
case "LB":
|
||||||
.putAll("MU", 3, 1, 1, 2, 2, 2)
|
return new int[] {3, 2, 1, 4, 2, 2};
|
||||||
.putAll("MV", 3, 4, 1, 4, 2, 2)
|
case "AD":
|
||||||
.putAll("MW", 4, 2, 1, 0, 2, 2)
|
case "BM":
|
||||||
.putAll("MX", 2, 4, 3, 4, 2, 2)
|
case "GL":
|
||||||
.putAll("MY", 2, 1, 3, 3, 2, 2)
|
case "LC":
|
||||||
.putAll("MZ", 3, 2, 2, 2, 2, 2)
|
return new int[] {1, 2, 0, 0, 2, 2};
|
||||||
.putAll("NA", 4, 3, 2, 2, 2, 2)
|
case "LK":
|
||||||
.putAll("NC", 3, 2, 4, 4, 2, 2)
|
return new int[] {3, 1, 3, 4, 4, 2};
|
||||||
.putAll("NE", 4, 4, 4, 4, 2, 2)
|
case "LR":
|
||||||
.putAll("NF", 2, 2, 2, 2, 2, 2)
|
return new int[] {3, 4, 4, 3, 2, 2};
|
||||||
.putAll("NG", 3, 4, 1, 1, 2, 2)
|
case "LS":
|
||||||
.putAll("NI", 2, 3, 4, 3, 2, 2)
|
return new int[] {3, 3, 4, 3, 2, 2};
|
||||||
.putAll("NL", 0, 0, 3, 2, 0, 4)
|
case "LU":
|
||||||
.putAll("NO", 0, 0, 2, 0, 0, 2)
|
return new int[] {1, 0, 2, 2, 2, 2};
|
||||||
.putAll("NP", 2, 1, 4, 3, 2, 2)
|
case "MC":
|
||||||
.putAll("NR", 3, 2, 2, 0, 2, 2)
|
return new int[] {0, 2, 2, 0, 2, 2};
|
||||||
.putAll("NU", 4, 2, 2, 2, 2, 2)
|
case "JO":
|
||||||
.putAll("NZ", 1, 0, 1, 2, 4, 2)
|
case "ME":
|
||||||
.putAll("OM", 2, 3, 1, 3, 4, 2)
|
return new int[] {1, 0, 0, 1, 2, 2};
|
||||||
.putAll("PA", 1, 3, 3, 3, 2, 2)
|
case "MF":
|
||||||
.putAll("PE", 2, 3, 4, 4, 4, 2)
|
return new int[] {1, 2, 1, 0, 2, 2};
|
||||||
.putAll("PF", 2, 3, 3, 1, 2, 2)
|
case "MG":
|
||||||
.putAll("PG", 4, 4, 3, 2, 2, 2)
|
return new int[] {3, 4, 2, 2, 2, 2};
|
||||||
.putAll("PH", 2, 2, 3, 3, 3, 2)
|
case "MH":
|
||||||
.putAll("PK", 3, 2, 3, 3, 2, 2)
|
return new int[] {3, 2, 2, 4, 2, 2};
|
||||||
.putAll("PL", 1, 1, 2, 2, 3, 2)
|
case "ML":
|
||||||
.putAll("PM", 0, 2, 2, 2, 2, 2)
|
return new int[] {4, 3, 3, 1, 2, 2};
|
||||||
.putAll("PR", 2, 3, 2, 2, 3, 3)
|
case "MM":
|
||||||
.putAll("PS", 3, 4, 1, 2, 2, 2)
|
return new int[] {2, 4, 3, 3, 2, 2};
|
||||||
.putAll("PT", 0, 1, 0, 0, 2, 2)
|
case "MN":
|
||||||
.putAll("PW", 2, 2, 4, 1, 2, 2)
|
return new int[] {2, 0, 1, 2, 2, 2};
|
||||||
.putAll("PY", 2, 2, 3, 2, 2, 2)
|
case "MO":
|
||||||
.putAll("QA", 2, 4, 2, 4, 4, 2)
|
return new int[] {0, 2, 4, 4, 2, 2};
|
||||||
.putAll("RE", 1, 1, 1, 2, 2, 2)
|
case "GF":
|
||||||
.putAll("RO", 0, 0, 1, 1, 1, 2)
|
case "GP":
|
||||||
.putAll("RS", 1, 0, 0, 0, 2, 2)
|
case "MQ":
|
||||||
.putAll("RU", 0, 0, 0, 1, 2, 2)
|
return new int[] {2, 1, 2, 3, 2, 2};
|
||||||
.putAll("RW", 3, 4, 3, 0, 2, 2)
|
case "MR":
|
||||||
.putAll("SA", 2, 2, 1, 1, 2, 2)
|
return new int[] {4, 1, 3, 4, 2, 2};
|
||||||
.putAll("SB", 4, 2, 4, 3, 2, 2)
|
case "EE":
|
||||||
.putAll("SC", 4, 3, 0, 2, 2, 2)
|
case "LT":
|
||||||
.putAll("SD", 4, 4, 4, 4, 2, 2)
|
case "LV":
|
||||||
.putAll("SE", 0, 0, 0, 0, 0, 2)
|
case "MT":
|
||||||
.putAll("SG", 1, 1, 2, 3, 1, 4)
|
return new int[] {0, 0, 0, 0, 2, 2};
|
||||||
.putAll("SH", 4, 2, 2, 2, 2, 2)
|
case "MU":
|
||||||
.putAll("SI", 0, 0, 0, 0, 1, 2)
|
return new int[] {3, 1, 1, 2, 2, 2};
|
||||||
.putAll("SJ", 0, 2, 2, 2, 2, 2)
|
case "MV":
|
||||||
.putAll("SK", 0, 0, 0, 0, 0, 2)
|
return new int[] {3, 4, 1, 4, 2, 2};
|
||||||
.putAll("SL", 4, 3, 4, 1, 2, 2)
|
case "MW":
|
||||||
.putAll("SM", 0, 2, 2, 2, 2, 2)
|
return new int[] {4, 2, 1, 0, 2, 2};
|
||||||
.putAll("SN", 4, 4, 4, 4, 2, 2)
|
case "CG":
|
||||||
.putAll("SO", 3, 2, 3, 3, 2, 2)
|
case "MX":
|
||||||
.putAll("SR", 2, 3, 2, 2, 2, 2)
|
return new int[] {2, 4, 3, 4, 2, 2};
|
||||||
.putAll("SS", 4, 2, 2, 2, 2, 2)
|
case "BD":
|
||||||
.putAll("ST", 3, 2, 2, 2, 2, 2)
|
case "MY":
|
||||||
.putAll("SV", 2, 2, 3, 3, 2, 2)
|
return new int[] {2, 1, 3, 3, 2, 2};
|
||||||
.putAll("SX", 2, 2, 1, 0, 2, 2)
|
case "NA":
|
||||||
.putAll("SY", 4, 3, 4, 4, 2, 2)
|
return new int[] {4, 3, 2, 2, 2, 2};
|
||||||
.putAll("SZ", 4, 3, 2, 4, 2, 2)
|
case "AZ":
|
||||||
.putAll("TC", 2, 2, 1, 0, 2, 2)
|
case "NC":
|
||||||
.putAll("TD", 4, 4, 4, 4, 2, 2)
|
return new int[] {3, 2, 4, 4, 2, 2};
|
||||||
.putAll("TG", 3, 3, 2, 0, 2, 2)
|
case "NG":
|
||||||
.putAll("TH", 0, 3, 2, 3, 3, 0)
|
return new int[] {3, 4, 1, 1, 2, 2};
|
||||||
.putAll("TJ", 4, 2, 4, 4, 2, 2)
|
case "NI":
|
||||||
.putAll("TL", 4, 3, 4, 4, 2, 2)
|
return new int[] {2, 3, 4, 3, 2, 2};
|
||||||
.putAll("TM", 4, 2, 4, 2, 2, 2)
|
case "NL":
|
||||||
.putAll("TN", 2, 2, 1, 1, 2, 2)
|
return new int[] {0, 0, 3, 2, 0, 4};
|
||||||
.putAll("TO", 4, 2, 3, 3, 2, 2)
|
case "NO":
|
||||||
.putAll("TR", 1, 1, 0, 1, 2, 2)
|
return new int[] {0, 0, 2, 0, 0, 2};
|
||||||
.putAll("TT", 1, 4, 1, 1, 2, 2)
|
case "NP":
|
||||||
.putAll("TV", 4, 2, 2, 2, 2, 2)
|
return new int[] {2, 1, 4, 3, 2, 2};
|
||||||
.putAll("TW", 0, 0, 0, 0, 0, 0)
|
case "NR":
|
||||||
.putAll("TZ", 3, 4, 3, 3, 2, 2)
|
return new int[] {3, 2, 2, 0, 2, 2};
|
||||||
.putAll("UA", 0, 3, 1, 1, 2, 2)
|
case "NZ":
|
||||||
.putAll("UG", 3, 3, 3, 3, 2, 2)
|
return new int[] {1, 0, 1, 2, 4, 2};
|
||||||
.putAll("US", 1, 1, 2, 2, 3, 2)
|
case "OM":
|
||||||
.putAll("UY", 2, 2, 1, 2, 2, 2)
|
return new int[] {2, 3, 1, 3, 4, 2};
|
||||||
.putAll("UZ", 2, 2, 3, 4, 2, 2)
|
case "PA":
|
||||||
.putAll("VC", 1, 2, 2, 2, 2, 2)
|
return new int[] {1, 3, 3, 3, 2, 2};
|
||||||
.putAll("VE", 4, 4, 4, 4, 2, 2)
|
case "PE":
|
||||||
.putAll("VG", 2, 2, 1, 1, 2, 2)
|
return new int[] {2, 3, 4, 4, 4, 2};
|
||||||
.putAll("VI", 1, 2, 1, 3, 2, 2)
|
case "PF":
|
||||||
.putAll("VN", 0, 3, 3, 4, 2, 2)
|
return new int[] {2, 3, 3, 1, 2, 2};
|
||||||
.putAll("VU", 4, 2, 2, 1, 2, 2)
|
case "CU":
|
||||||
.putAll("WF", 4, 2, 2, 4, 2, 2)
|
case "PG":
|
||||||
.putAll("WS", 3, 1, 2, 1, 2, 2)
|
return new int[] {4, 4, 3, 2, 2, 2};
|
||||||
.putAll("XK", 1, 1, 1, 1, 2, 2)
|
case "PH":
|
||||||
.putAll("YE", 4, 4, 4, 4, 2, 2)
|
return new int[] {2, 2, 3, 3, 3, 2};
|
||||||
.putAll("YT", 4, 1, 1, 1, 2, 2)
|
case "PR":
|
||||||
.putAll("ZA", 3, 3, 1, 1, 1, 2)
|
return new int[] {2, 3, 2, 2, 3, 3};
|
||||||
.putAll("ZM", 3, 3, 4, 2, 2, 2)
|
case "PS":
|
||||||
.putAll("ZW", 3, 2, 4, 3, 2, 2)
|
return new int[] {3, 4, 1, 2, 2, 2};
|
||||||
.build();
|
case "PT":
|
||||||
|
return new int[] {0, 1, 0, 0, 2, 2};
|
||||||
|
case "PW":
|
||||||
|
return new int[] {2, 2, 4, 1, 2, 2};
|
||||||
|
case "PY":
|
||||||
|
return new int[] {2, 2, 3, 2, 2, 2};
|
||||||
|
case "QA":
|
||||||
|
return new int[] {2, 4, 2, 4, 4, 2};
|
||||||
|
case "RE":
|
||||||
|
return new int[] {1, 1, 1, 2, 2, 2};
|
||||||
|
case "RO":
|
||||||
|
return new int[] {0, 0, 1, 1, 1, 2};
|
||||||
|
case "GR":
|
||||||
|
case "HR":
|
||||||
|
case "MD":
|
||||||
|
case "MK":
|
||||||
|
case "RS":
|
||||||
|
return new int[] {1, 0, 0, 0, 2, 2};
|
||||||
|
case "RU":
|
||||||
|
return new int[] {0, 0, 0, 1, 2, 2};
|
||||||
|
case "RW":
|
||||||
|
return new int[] {3, 4, 3, 0, 2, 2};
|
||||||
|
case "KI":
|
||||||
|
case "KM":
|
||||||
|
case "LY":
|
||||||
|
case "SB":
|
||||||
|
return new int[] {4, 2, 4, 3, 2, 2};
|
||||||
|
case "SC":
|
||||||
|
return new int[] {4, 3, 0, 2, 2, 2};
|
||||||
|
case "SG":
|
||||||
|
return new int[] {1, 1, 2, 3, 1, 4};
|
||||||
|
case "BG":
|
||||||
|
case "CZ":
|
||||||
|
case "SI":
|
||||||
|
return new int[] {0, 0, 0, 0, 1, 2};
|
||||||
|
case "AT":
|
||||||
|
case "CH":
|
||||||
|
case "IS":
|
||||||
|
case "SE":
|
||||||
|
case "SK":
|
||||||
|
return new int[] {0, 0, 0, 0, 0, 2};
|
||||||
|
case "SL":
|
||||||
|
return new int[] {4, 3, 4, 1, 2, 2};
|
||||||
|
case "AX":
|
||||||
|
case "GI":
|
||||||
|
case "LI":
|
||||||
|
case "MP":
|
||||||
|
case "PM":
|
||||||
|
case "SJ":
|
||||||
|
case "SM":
|
||||||
|
return new int[] {0, 2, 2, 2, 2, 2};
|
||||||
|
case "HN":
|
||||||
|
case "PK":
|
||||||
|
case "SO":
|
||||||
|
return new int[] {3, 2, 3, 3, 2, 2};
|
||||||
|
case "BR":
|
||||||
|
case "SR":
|
||||||
|
return new int[] {2, 3, 2, 2, 2, 2};
|
||||||
|
case "FK":
|
||||||
|
case "KP":
|
||||||
|
case "MA":
|
||||||
|
case "MZ":
|
||||||
|
case "ST":
|
||||||
|
return new int[] {3, 2, 2, 2, 2, 2};
|
||||||
|
case "SV":
|
||||||
|
return new int[] {2, 2, 3, 3, 2, 2};
|
||||||
|
case "SZ":
|
||||||
|
return new int[] {4, 3, 2, 4, 2, 2};
|
||||||
|
case "SX":
|
||||||
|
case "TC":
|
||||||
|
return new int[] {2, 2, 1, 0, 2, 2};
|
||||||
|
case "TG":
|
||||||
|
return new int[] {3, 3, 2, 0, 2, 2};
|
||||||
|
case "TH":
|
||||||
|
return new int[] {0, 3, 2, 3, 3, 0};
|
||||||
|
case "TJ":
|
||||||
|
return new int[] {4, 2, 4, 4, 2, 2};
|
||||||
|
case "BI":
|
||||||
|
case "DZ":
|
||||||
|
case "SY":
|
||||||
|
case "TL":
|
||||||
|
return new int[] {4, 3, 4, 4, 2, 2};
|
||||||
|
case "TM":
|
||||||
|
return new int[] {4, 2, 4, 2, 2, 2};
|
||||||
|
case "TO":
|
||||||
|
return new int[] {4, 2, 3, 3, 2, 2};
|
||||||
|
case "TR":
|
||||||
|
return new int[] {1, 1, 0, 1, 2, 2};
|
||||||
|
case "TT":
|
||||||
|
return new int[] {1, 4, 1, 1, 2, 2};
|
||||||
|
case "AQ":
|
||||||
|
case "ER":
|
||||||
|
case "IO":
|
||||||
|
case "NU":
|
||||||
|
case "SH":
|
||||||
|
case "SS":
|
||||||
|
case "TV":
|
||||||
|
return new int[] {4, 2, 2, 2, 2, 2};
|
||||||
|
case "TW":
|
||||||
|
return new int[] {0, 0, 0, 0, 0, 0};
|
||||||
|
case "GW":
|
||||||
|
case "TZ":
|
||||||
|
return new int[] {3, 4, 3, 3, 2, 2};
|
||||||
|
case "UA":
|
||||||
|
return new int[] {0, 3, 1, 1, 2, 2};
|
||||||
|
case "IQ":
|
||||||
|
case "UG":
|
||||||
|
return new int[] {3, 3, 3, 3, 2, 2};
|
||||||
|
case "CL":
|
||||||
|
case "PL":
|
||||||
|
case "US":
|
||||||
|
return new int[] {1, 1, 2, 2, 3, 2};
|
||||||
|
case "LA":
|
||||||
|
case "UY":
|
||||||
|
return new int[] {2, 2, 1, 2, 2, 2};
|
||||||
|
case "UZ":
|
||||||
|
return new int[] {2, 2, 3, 4, 2, 2};
|
||||||
|
case "AI":
|
||||||
|
case "BL":
|
||||||
|
case "CX":
|
||||||
|
case "DM":
|
||||||
|
case "GD":
|
||||||
|
case "MS":
|
||||||
|
case "VC":
|
||||||
|
return new int[] {1, 2, 2, 2, 2, 2};
|
||||||
|
case "SA":
|
||||||
|
case "TN":
|
||||||
|
case "VG":
|
||||||
|
return new int[] {2, 2, 1, 1, 2, 2};
|
||||||
|
case "VI":
|
||||||
|
return new int[] {1, 2, 1, 3, 2, 2};
|
||||||
|
case "VN":
|
||||||
|
return new int[] {0, 3, 3, 4, 2, 2};
|
||||||
|
case "VU":
|
||||||
|
return new int[] {4, 2, 2, 1, 2, 2};
|
||||||
|
case "GM":
|
||||||
|
case "WF":
|
||||||
|
return new int[] {4, 2, 2, 4, 2, 2};
|
||||||
|
case "WS":
|
||||||
|
return new int[] {3, 1, 2, 1, 2, 2};
|
||||||
|
case "XK":
|
||||||
|
return new int[] {1, 1, 1, 1, 2, 2};
|
||||||
|
case "AF":
|
||||||
|
case "HT":
|
||||||
|
case "NE":
|
||||||
|
case "SD":
|
||||||
|
case "SN":
|
||||||
|
case "TD":
|
||||||
|
case "VE":
|
||||||
|
case "YE":
|
||||||
|
return new int[] {4, 4, 4, 4, 2, 2};
|
||||||
|
case "YT":
|
||||||
|
return new int[] {4, 1, 1, 1, 2, 2};
|
||||||
|
case "ZA":
|
||||||
|
return new int[] {3, 3, 1, 1, 1, 2};
|
||||||
|
case "ZM":
|
||||||
|
return new int[] {3, 3, 4, 2, 2, 2};
|
||||||
|
case "ZW":
|
||||||
|
return new int[] {3, 2, 4, 3, 2, 2};
|
||||||
|
default:
|
||||||
|
return new int[] {2, 2, 2, 2, 2, 2};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,8 @@ public class DebugTextViewHelper implements Player.Listener, Runnable {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return String.format(
|
return String.format(
|
||||||
"playWhenReady:%s playbackState:%s window:%s",
|
"playWhenReady:%s playbackState:%s item:%s",
|
||||||
player.getPlayWhenReady(), playbackStateString, player.getCurrentWindowIndex());
|
player.getPlayWhenReady(), playbackStateString, player.getCurrentMediaItemIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a string containing video debugging information. */
|
/** Returns a string containing video debugging information. */
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -950,7 +950,7 @@ public class PlayerControlView extends FrameLayout {
|
||||||
int adGroupCount = 0;
|
int adGroupCount = 0;
|
||||||
Timeline timeline = player.getCurrentTimeline();
|
Timeline timeline = player.getCurrentTimeline();
|
||||||
if (!timeline.isEmpty()) {
|
if (!timeline.isEmpty()) {
|
||||||
int currentWindowIndex = player.getCurrentWindowIndex();
|
int currentWindowIndex = player.getCurrentMediaItemIndex();
|
||||||
int firstWindowIndex = multiWindowTimeBar ? 0 : currentWindowIndex;
|
int firstWindowIndex = multiWindowTimeBar ? 0 : currentWindowIndex;
|
||||||
int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex;
|
int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex;
|
||||||
for (int i = firstWindowIndex; i <= lastWindowIndex; i++) {
|
for (int i = firstWindowIndex; i <= lastWindowIndex; i++) {
|
||||||
|
|
@ -1110,7 +1110,7 @@ public class PlayerControlView extends FrameLayout {
|
||||||
windowIndex++;
|
windowIndex++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
windowIndex = player.getCurrentWindowIndex();
|
windowIndex = player.getCurrentMediaItemIndex();
|
||||||
}
|
}
|
||||||
seekTo(player, windowIndex, positionMs);
|
seekTo(player, windowIndex, positionMs);
|
||||||
updateProgress();
|
updateProgress();
|
||||||
|
|
@ -1228,7 +1228,7 @@ public class PlayerControlView extends FrameLayout {
|
||||||
if (state == Player.STATE_IDLE) {
|
if (state == Player.STATE_IDLE) {
|
||||||
player.prepare();
|
player.prepare();
|
||||||
} else if (state == Player.STATE_ENDED) {
|
} else if (state == Player.STATE_ENDED) {
|
||||||
seekTo(player, player.getCurrentWindowIndex(), C.TIME_UNSET);
|
seekTo(player, player.getCurrentMediaItemIndex(), C.TIME_UNSET);
|
||||||
}
|
}
|
||||||
player.play();
|
player.play();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -605,9 +605,9 @@ public class PlayerNotificationManager {
|
||||||
public static final String ACTION_PLAY = "com.google.android.exoplayer.play";
|
public static final String ACTION_PLAY = "com.google.android.exoplayer.play";
|
||||||
/** The action which pauses playback. */
|
/** The action which pauses playback. */
|
||||||
public static final String ACTION_PAUSE = "com.google.android.exoplayer.pause";
|
public static final String ACTION_PAUSE = "com.google.android.exoplayer.pause";
|
||||||
/** The action which skips to the previous window. */
|
/** The action which skips to the previous media item. */
|
||||||
public static final String ACTION_PREVIOUS = "com.google.android.exoplayer.prev";
|
public static final String ACTION_PREVIOUS = "com.google.android.exoplayer.prev";
|
||||||
/** The action which skips to the next window. */
|
/** The action which skips to the next media item. */
|
||||||
public static final String ACTION_NEXT = "com.google.android.exoplayer.next";
|
public static final String ACTION_NEXT = "com.google.android.exoplayer.next";
|
||||||
/** The action which fast forwards. */
|
/** The action which fast forwards. */
|
||||||
public static final String ACTION_FAST_FORWARD = "com.google.android.exoplayer.ffwd";
|
public static final String ACTION_FAST_FORWARD = "com.google.android.exoplayer.ffwd";
|
||||||
|
|
@ -1095,7 +1095,7 @@ public class PlayerNotificationManager {
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>The media is {@link Player#isPlaying() actively playing}.
|
* <li>The media is {@link Player#isPlaying() actively playing}.
|
||||||
* <li>The media is not {@link Player#isCurrentWindowDynamic() dynamically changing its
|
* <li>The media is not {@link Player#isCurrentMediaItemDynamic() dynamically changing its
|
||||||
* duration} (like for example a live stream).
|
* duration} (like for example a live stream).
|
||||||
* <li>The media is not {@link Player#isPlayingAd() interrupted by an ad}.
|
* <li>The media is not {@link Player#isPlayingAd() interrupted by an ad}.
|
||||||
* <li>The media is played at {@link Player#getPlaybackParameters() regular speed}.
|
* <li>The media is played at {@link Player#getPlaybackParameters() regular speed}.
|
||||||
|
|
@ -1253,7 +1253,7 @@ public class PlayerNotificationManager {
|
||||||
&& useChronometer
|
&& useChronometer
|
||||||
&& player.isPlaying()
|
&& player.isPlaying()
|
||||||
&& !player.isPlayingAd()
|
&& !player.isPlayingAd()
|
||||||
&& !player.isCurrentWindowDynamic()
|
&& !player.isCurrentMediaItemDynamic()
|
||||||
&& player.getPlaybackParameters().speed == 1f) {
|
&& player.getPlaybackParameters().speed == 1f) {
|
||||||
builder
|
builder
|
||||||
.setWhen(System.currentTimeMillis() - player.getContentPosition())
|
.setWhen(System.currentTimeMillis() - player.getContentPosition())
|
||||||
|
|
@ -1531,7 +1531,7 @@ public class PlayerNotificationManager {
|
||||||
if (player.getPlaybackState() == Player.STATE_IDLE) {
|
if (player.getPlaybackState() == Player.STATE_IDLE) {
|
||||||
player.prepare();
|
player.prepare();
|
||||||
} else if (player.getPlaybackState() == Player.STATE_ENDED) {
|
} else if (player.getPlaybackState() == Player.STATE_ENDED) {
|
||||||
player.seekToDefaultPosition(player.getCurrentWindowIndex());
|
player.seekToDefaultPosition(player.getCurrentMediaItemIndex());
|
||||||
}
|
}
|
||||||
player.play();
|
player.play();
|
||||||
} else if (ACTION_PAUSE.equals(action)) {
|
} else if (ACTION_PAUSE.equals(action)) {
|
||||||
|
|
|
||||||
|
|
@ -1501,8 +1501,8 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
if (lastPeriodIndexWithTracks != C.INDEX_UNSET) {
|
if (lastPeriodIndexWithTracks != C.INDEX_UNSET) {
|
||||||
int lastWindowIndexWithTracks =
|
int lastWindowIndexWithTracks =
|
||||||
timeline.getPeriod(lastPeriodIndexWithTracks, period).windowIndex;
|
timeline.getPeriod(lastPeriodIndexWithTracks, period).windowIndex;
|
||||||
if (player.getCurrentWindowIndex() == lastWindowIndexWithTracks) {
|
if (player.getCurrentMediaItemIndex() == lastWindowIndexWithTracks) {
|
||||||
// We're in the same window. Suppress the update.
|
// We're in the same media item. Suppress the update.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1269,7 +1269,7 @@ public class StyledPlayerControlView extends FrameLayout {
|
||||||
int adGroupCount = 0;
|
int adGroupCount = 0;
|
||||||
Timeline timeline = player.getCurrentTimeline();
|
Timeline timeline = player.getCurrentTimeline();
|
||||||
if (!timeline.isEmpty()) {
|
if (!timeline.isEmpty()) {
|
||||||
int currentWindowIndex = player.getCurrentWindowIndex();
|
int currentWindowIndex = player.getCurrentMediaItemIndex();
|
||||||
int firstWindowIndex = multiWindowTimeBar ? 0 : currentWindowIndex;
|
int firstWindowIndex = multiWindowTimeBar ? 0 : currentWindowIndex;
|
||||||
int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex;
|
int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex;
|
||||||
for (int i = firstWindowIndex; i <= lastWindowIndex; i++) {
|
for (int i = firstWindowIndex; i <= lastWindowIndex; i++) {
|
||||||
|
|
@ -1453,7 +1453,7 @@ public class StyledPlayerControlView extends FrameLayout {
|
||||||
windowIndex++;
|
windowIndex++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
windowIndex = player.getCurrentWindowIndex();
|
windowIndex = player.getCurrentMediaItemIndex();
|
||||||
}
|
}
|
||||||
seekTo(player, windowIndex, positionMs);
|
seekTo(player, windowIndex, positionMs);
|
||||||
updateProgress();
|
updateProgress();
|
||||||
|
|
@ -1616,13 +1616,12 @@ public class StyledPlayerControlView extends FrameLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private void dispatchPlay(Player player) {
|
private void dispatchPlay(Player player) {
|
||||||
@State int state = player.getPlaybackState();
|
@State int state = player.getPlaybackState();
|
||||||
if (state == Player.STATE_IDLE) {
|
if (state == Player.STATE_IDLE) {
|
||||||
player.prepare();
|
player.prepare();
|
||||||
} else if (state == Player.STATE_ENDED) {
|
} else if (state == Player.STATE_ENDED) {
|
||||||
seekTo(player, player.getCurrentWindowIndex(), C.TIME_UNSET);
|
seekTo(player, player.getCurrentMediaItemIndex(), C.TIME_UNSET);
|
||||||
}
|
}
|
||||||
player.play();
|
player.play();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1540,8 +1540,8 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
if (lastPeriodIndexWithTracks != C.INDEX_UNSET) {
|
if (lastPeriodIndexWithTracks != C.INDEX_UNSET) {
|
||||||
int lastWindowIndexWithTracks =
|
int lastWindowIndexWithTracks =
|
||||||
timeline.getPeriod(lastPeriodIndexWithTracks, period).windowIndex;
|
timeline.getPeriod(lastPeriodIndexWithTracks, period).windowIndex;
|
||||||
if (player.getCurrentWindowIndex() == lastWindowIndexWithTracks) {
|
if (player.getCurrentMediaItemIndex() == lastWindowIndexWithTracks) {
|
||||||
// We're in the same window. Suppress the update.
|
// We're in the same media item. Suppress the update.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -284,12 +284,12 @@ public class TestPlayerRunHelper {
|
||||||
* <p>If a playback error occurs it will be thrown wrapped in an {@link IllegalStateException}.
|
* <p>If a playback error occurs it will be thrown wrapped in an {@link IllegalStateException}.
|
||||||
*
|
*
|
||||||
* @param player The {@link Player}.
|
* @param player The {@link Player}.
|
||||||
* @param windowIndex The window.
|
* @param mediaItemIndex The index of the media item.
|
||||||
* @param positionMs The position within the window, in milliseconds.
|
* @param positionMs The position within the media item, in milliseconds.
|
||||||
* @throws TimeoutException If the {@link RobolectricUtil#DEFAULT_TIMEOUT_MS default timeout} is
|
* @throws TimeoutException If the {@link RobolectricUtil#DEFAULT_TIMEOUT_MS default timeout} is
|
||||||
* exceeded.
|
* exceeded.
|
||||||
*/
|
*/
|
||||||
public static void playUntilPosition(ExoPlayer player, int windowIndex, long positionMs)
|
public static void playUntilPosition(ExoPlayer player, int mediaItemIndex, long positionMs)
|
||||||
throws TimeoutException {
|
throws TimeoutException {
|
||||||
verifyMainTestThread(player);
|
verifyMainTestThread(player);
|
||||||
Looper applicationLooper = Util.getCurrentOrMainLooper();
|
Looper applicationLooper = Util.getCurrentOrMainLooper();
|
||||||
|
|
@ -315,7 +315,7 @@ public class TestPlayerRunHelper {
|
||||||
// Ignore.
|
// Ignore.
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setPosition(windowIndex, positionMs)
|
.setPosition(mediaItemIndex, positionMs)
|
||||||
.send();
|
.send();
|
||||||
player.play();
|
player.play();
|
||||||
runMainLooperUntil(() -> messageHandled.get() || player.getPlayerError() != null);
|
runMainLooperUntil(() -> messageHandled.get() || player.getPlayerError() != null);
|
||||||
|
|
@ -326,18 +326,19 @@ public class TestPlayerRunHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls {@link Player#play()}, runs tasks of the main {@link Looper} until the {@code player}
|
* Calls {@link Player#play()}, runs tasks of the main {@link Looper} until the {@code player}
|
||||||
* reaches the specified window or a playback error occurs, and then pauses the {@code player}.
|
* reaches the specified media item or a playback error occurs, and then pauses the {@code
|
||||||
|
* player}.
|
||||||
*
|
*
|
||||||
* <p>If a playback error occurs it will be thrown wrapped in an {@link IllegalStateException}.
|
* <p>If a playback error occurs it will be thrown wrapped in an {@link IllegalStateException}.
|
||||||
*
|
*
|
||||||
* @param player The {@link Player}.
|
* @param player The {@link Player}.
|
||||||
* @param windowIndex The window.
|
* @param mediaItemIndex The index of the media item.
|
||||||
* @throws TimeoutException If the {@link RobolectricUtil#DEFAULT_TIMEOUT_MS default timeout} is
|
* @throws TimeoutException If the {@link RobolectricUtil#DEFAULT_TIMEOUT_MS default timeout} is
|
||||||
* exceeded.
|
* exceeded.
|
||||||
*/
|
*/
|
||||||
public static void playUntilStartOfWindow(ExoPlayer player, int windowIndex)
|
public static void playUntilStartOfMediaItem(ExoPlayer player, int mediaItemIndex)
|
||||||
throws TimeoutException {
|
throws TimeoutException {
|
||||||
playUntilPosition(player, windowIndex, /* positionMs= */ 0);
|
playUntilPosition(player, mediaItemIndex, /* positionMs= */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ public abstract class Action {
|
||||||
/** Calls {@link Player#seekTo(long)} or {@link Player#seekTo(int, long)}. */
|
/** Calls {@link Player#seekTo(long)} or {@link Player#seekTo(int, long)}. */
|
||||||
public static final class Seek extends Action {
|
public static final class Seek extends Action {
|
||||||
|
|
||||||
@Nullable private final Integer windowIndex;
|
@Nullable private final Integer mediaItemIndex;
|
||||||
private final long positionMs;
|
private final long positionMs;
|
||||||
private final boolean catchIllegalSeekException;
|
private final boolean catchIllegalSeekException;
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ public abstract class Action {
|
||||||
*/
|
*/
|
||||||
public Seek(String tag, long positionMs) {
|
public Seek(String tag, long positionMs) {
|
||||||
super(tag, "Seek:" + positionMs);
|
super(tag, "Seek:" + positionMs);
|
||||||
this.windowIndex = null;
|
this.mediaItemIndex = null;
|
||||||
this.positionMs = positionMs;
|
this.positionMs = positionMs;
|
||||||
catchIllegalSeekException = false;
|
catchIllegalSeekException = false;
|
||||||
}
|
}
|
||||||
|
|
@ -142,14 +142,15 @@ public abstract class Action {
|
||||||
* Action calls {@link Player#seekTo(int, long)}.
|
* Action calls {@link Player#seekTo(int, long)}.
|
||||||
*
|
*
|
||||||
* @param tag A tag to use for logging.
|
* @param tag A tag to use for logging.
|
||||||
* @param windowIndex The window to seek to.
|
* @param mediaItemIndex The media item to seek to.
|
||||||
* @param positionMs The seek position.
|
* @param positionMs The seek position.
|
||||||
* @param catchIllegalSeekException Whether {@link IllegalSeekPositionException} should be
|
* @param catchIllegalSeekException Whether {@link IllegalSeekPositionException} should be
|
||||||
* silently caught or not.
|
* silently caught or not.
|
||||||
*/
|
*/
|
||||||
public Seek(String tag, int windowIndex, long positionMs, boolean catchIllegalSeekException) {
|
public Seek(
|
||||||
|
String tag, int mediaItemIndex, long positionMs, boolean catchIllegalSeekException) {
|
||||||
super(tag, "Seek:" + positionMs);
|
super(tag, "Seek:" + positionMs);
|
||||||
this.windowIndex = windowIndex;
|
this.mediaItemIndex = mediaItemIndex;
|
||||||
this.positionMs = positionMs;
|
this.positionMs = positionMs;
|
||||||
this.catchIllegalSeekException = catchIllegalSeekException;
|
this.catchIllegalSeekException = catchIllegalSeekException;
|
||||||
}
|
}
|
||||||
|
|
@ -158,10 +159,10 @@ public abstract class Action {
|
||||||
protected void doActionImpl(
|
protected void doActionImpl(
|
||||||
ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
|
ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
|
||||||
try {
|
try {
|
||||||
if (windowIndex == null) {
|
if (mediaItemIndex == null) {
|
||||||
player.seekTo(positionMs);
|
player.seekTo(positionMs);
|
||||||
} else {
|
} else {
|
||||||
player.seekTo(windowIndex, positionMs);
|
player.seekTo(mediaItemIndex, positionMs);
|
||||||
}
|
}
|
||||||
} catch (IllegalSeekPositionException e) {
|
} catch (IllegalSeekPositionException e) {
|
||||||
if (!catchIllegalSeekException) {
|
if (!catchIllegalSeekException) {
|
||||||
|
|
@ -174,20 +175,20 @@ public abstract class Action {
|
||||||
/** Calls {@link ExoPlayer#setMediaSources(List, int, long)}. */
|
/** Calls {@link ExoPlayer#setMediaSources(List, int, long)}. */
|
||||||
public static final class SetMediaItems extends Action {
|
public static final class SetMediaItems extends Action {
|
||||||
|
|
||||||
private final int windowIndex;
|
private final int mediaItemIndex;
|
||||||
private final long positionMs;
|
private final long positionMs;
|
||||||
private final MediaSource[] mediaSources;
|
private final MediaSource[] mediaSources;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param tag A tag to use for logging.
|
* @param tag A tag to use for logging.
|
||||||
* @param windowIndex The window index to start playback from.
|
* @param mediaItemIndex The media item index to start playback from.
|
||||||
* @param positionMs The position in milliseconds to start playback from.
|
* @param positionMs The position in milliseconds to start playback from.
|
||||||
* @param mediaSources The media sources to populate the playlist with.
|
* @param mediaSources The media sources to populate the playlist with.
|
||||||
*/
|
*/
|
||||||
public SetMediaItems(
|
public SetMediaItems(
|
||||||
String tag, int windowIndex, long positionMs, MediaSource... mediaSources) {
|
String tag, int mediaItemIndex, long positionMs, MediaSource... mediaSources) {
|
||||||
super(tag, "SetMediaItems");
|
super(tag, "SetMediaItems");
|
||||||
this.windowIndex = windowIndex;
|
this.mediaItemIndex = mediaItemIndex;
|
||||||
this.positionMs = positionMs;
|
this.positionMs = positionMs;
|
||||||
this.mediaSources = mediaSources;
|
this.mediaSources = mediaSources;
|
||||||
}
|
}
|
||||||
|
|
@ -195,7 +196,7 @@ public abstract class Action {
|
||||||
@Override
|
@Override
|
||||||
protected void doActionImpl(
|
protected void doActionImpl(
|
||||||
ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
|
ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
|
||||||
player.setMediaSources(Arrays.asList(mediaSources), windowIndex, positionMs);
|
player.setMediaSources(Arrays.asList(mediaSources), mediaItemIndex, positionMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -553,7 +554,7 @@ public abstract class Action {
|
||||||
public static final class SendMessages extends Action {
|
public static final class SendMessages extends Action {
|
||||||
|
|
||||||
private final Target target;
|
private final Target target;
|
||||||
private final int windowIndex;
|
private final int mediaItemIndex;
|
||||||
private final long positionMs;
|
private final long positionMs;
|
||||||
private final boolean deleteAfterDelivery;
|
private final boolean deleteAfterDelivery;
|
||||||
|
|
||||||
|
|
@ -566,7 +567,7 @@ public abstract class Action {
|
||||||
this(
|
this(
|
||||||
tag,
|
tag,
|
||||||
target,
|
target,
|
||||||
/* windowIndex= */ C.INDEX_UNSET,
|
/* mediaItemIndex= */ C.INDEX_UNSET,
|
||||||
positionMs,
|
positionMs,
|
||||||
/* deleteAfterDelivery= */ true);
|
/* deleteAfterDelivery= */ true);
|
||||||
}
|
}
|
||||||
|
|
@ -574,16 +575,20 @@ public abstract class Action {
|
||||||
/**
|
/**
|
||||||
* @param tag A tag to use for logging.
|
* @param tag A tag to use for logging.
|
||||||
* @param target A message target.
|
* @param target A message target.
|
||||||
* @param windowIndex The window index at which the message should be sent, or {@link
|
* @param mediaItemIndex The media item index at which the message should be sent, or {@link
|
||||||
* C#INDEX_UNSET} for the current window.
|
* C#INDEX_UNSET} for the current media item.
|
||||||
* @param positionMs The position at which the message should be sent, in milliseconds.
|
* @param positionMs The position at which the message should be sent, in milliseconds.
|
||||||
* @param deleteAfterDelivery Whether the message will be deleted after delivery.
|
* @param deleteAfterDelivery Whether the message will be deleted after delivery.
|
||||||
*/
|
*/
|
||||||
public SendMessages(
|
public SendMessages(
|
||||||
String tag, Target target, int windowIndex, long positionMs, boolean deleteAfterDelivery) {
|
String tag,
|
||||||
|
Target target,
|
||||||
|
int mediaItemIndex,
|
||||||
|
long positionMs,
|
||||||
|
boolean deleteAfterDelivery) {
|
||||||
super(tag, "SendMessages");
|
super(tag, "SendMessages");
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.windowIndex = windowIndex;
|
this.mediaItemIndex = mediaItemIndex;
|
||||||
this.positionMs = positionMs;
|
this.positionMs = positionMs;
|
||||||
this.deleteAfterDelivery = deleteAfterDelivery;
|
this.deleteAfterDelivery = deleteAfterDelivery;
|
||||||
}
|
}
|
||||||
|
|
@ -595,8 +600,8 @@ public abstract class Action {
|
||||||
((PlayerTarget) target).setPlayer(player);
|
((PlayerTarget) target).setPlayer(player);
|
||||||
}
|
}
|
||||||
PlayerMessage message = player.createMessage(target);
|
PlayerMessage message = player.createMessage(target);
|
||||||
if (windowIndex != C.INDEX_UNSET) {
|
if (mediaItemIndex != C.INDEX_UNSET) {
|
||||||
message.setPosition(windowIndex, positionMs);
|
message.setPosition(mediaItemIndex, positionMs);
|
||||||
} else {
|
} else {
|
||||||
message.setPosition(positionMs);
|
message.setPosition(positionMs);
|
||||||
}
|
}
|
||||||
|
|
@ -661,17 +666,17 @@ public abstract class Action {
|
||||||
*/
|
*/
|
||||||
public static final class PlayUntilPosition extends Action {
|
public static final class PlayUntilPosition extends Action {
|
||||||
|
|
||||||
private final int windowIndex;
|
private final int mediaItemIndex;
|
||||||
private final long positionMs;
|
private final long positionMs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param tag A tag to use for logging.
|
* @param tag A tag to use for logging.
|
||||||
* @param windowIndex The window index at which the player should be paused again.
|
* @param mediaItemIndex The media item index at which the player should be paused again.
|
||||||
* @param positionMs The position in that window at which the player should be paused again.
|
* @param positionMs The position in that media item at which the player should be paused again.
|
||||||
*/
|
*/
|
||||||
public PlayUntilPosition(String tag, int windowIndex, long positionMs) {
|
public PlayUntilPosition(String tag, int mediaItemIndex, long positionMs) {
|
||||||
super(tag, "PlayUntilPosition:" + windowIndex + ":" + positionMs);
|
super(tag, "PlayUntilPosition:" + mediaItemIndex + ":" + positionMs);
|
||||||
this.windowIndex = windowIndex;
|
this.mediaItemIndex = mediaItemIndex;
|
||||||
this.positionMs = positionMs;
|
this.positionMs = positionMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -704,7 +709,7 @@ public abstract class Action {
|
||||||
// Ignore.
|
// Ignore.
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setPosition(windowIndex, positionMs)
|
.setPosition(mediaItemIndex, positionMs)
|
||||||
.send();
|
.send();
|
||||||
if (nextAction != null) {
|
if (nextAction != null) {
|
||||||
// Schedule another message on this test thread to continue action schedule.
|
// Schedule another message on this test thread to continue action schedule.
|
||||||
|
|
@ -712,7 +717,7 @@ public abstract class Action {
|
||||||
.createMessage(
|
.createMessage(
|
||||||
(messageType, payload) ->
|
(messageType, payload) ->
|
||||||
nextAction.schedule(player, trackSelector, surface, handler))
|
nextAction.schedule(player, trackSelector, surface, handler))
|
||||||
.setPosition(windowIndex, positionMs)
|
.setPosition(mediaItemIndex, positionMs)
|
||||||
.setLooper(applicationLooper)
|
.setLooper(applicationLooper)
|
||||||
.send();
|
.send();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,24 +161,25 @@ public final class ActionSchedule {
|
||||||
/**
|
/**
|
||||||
* Schedules a seek action.
|
* Schedules a seek action.
|
||||||
*
|
*
|
||||||
* @param windowIndex The window to seek to.
|
* @param mediaItemIndex The media item to seek to.
|
||||||
* @param positionMs The seek position.
|
* @param positionMs The seek position.
|
||||||
* @return The builder, for convenience.
|
* @return The builder, for convenience.
|
||||||
*/
|
*/
|
||||||
public Builder seek(int windowIndex, long positionMs) {
|
public Builder seek(int mediaItemIndex, long positionMs) {
|
||||||
return apply(new Seek(tag, windowIndex, positionMs, /* catchIllegalSeekException= */ false));
|
return apply(
|
||||||
|
new Seek(tag, mediaItemIndex, positionMs, /* catchIllegalSeekException= */ false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedules a seek action to be executed.
|
* Schedules a seek action to be executed.
|
||||||
*
|
*
|
||||||
* @param windowIndex The window to seek to.
|
* @param mediaItemIndex The media item to seek to.
|
||||||
* @param positionMs The seek position.
|
* @param positionMs The seek position.
|
||||||
* @param catchIllegalSeekException Whether an illegal seek position should be caught or not.
|
* @param catchIllegalSeekException Whether an illegal seek position should be caught or not.
|
||||||
* @return The builder, for convenience.
|
* @return The builder, for convenience.
|
||||||
*/
|
*/
|
||||||
public Builder seek(int windowIndex, long positionMs, boolean catchIllegalSeekException) {
|
public Builder seek(int mediaItemIndex, long positionMs, boolean catchIllegalSeekException) {
|
||||||
return apply(new Seek(tag, windowIndex, positionMs, catchIllegalSeekException));
|
return apply(new Seek(tag, mediaItemIndex, positionMs, catchIllegalSeekException));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -247,23 +248,23 @@ public final class ActionSchedule {
|
||||||
* Schedules a play action, waits until the player reaches the specified position, and pauses
|
* Schedules a play action, waits until the player reaches the specified position, and pauses
|
||||||
* the player again.
|
* the player again.
|
||||||
*
|
*
|
||||||
* @param windowIndex The window index at which the player should be paused again.
|
* @param mediaItemIndex The media item index at which the player should be paused again.
|
||||||
* @param positionMs The position in that window at which the player should be paused again.
|
* @param positionMs The position in that media item at which the player should be paused again.
|
||||||
* @return The builder, for convenience.
|
* @return The builder, for convenience.
|
||||||
*/
|
*/
|
||||||
public Builder playUntilPosition(int windowIndex, long positionMs) {
|
public Builder playUntilPosition(int mediaItemIndex, long positionMs) {
|
||||||
return apply(new PlayUntilPosition(tag, windowIndex, positionMs));
|
return apply(new PlayUntilPosition(tag, mediaItemIndex, positionMs));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedules a play action, waits until the player reaches the start of the specified window,
|
* Schedules a play action, waits until the player reaches the start of the specified media
|
||||||
* and pauses the player again.
|
* item, and pauses the player again.
|
||||||
*
|
*
|
||||||
* @param windowIndex The window index at which the player should be paused again.
|
* @param mediaItemIndex The media item index at which the player should be paused again.
|
||||||
* @return The builder, for convenience.
|
* @return The builder, for convenience.
|
||||||
*/
|
*/
|
||||||
public Builder playUntilStartOfWindow(int windowIndex) {
|
public Builder playUntilStartOfMediaItem(int mediaItemIndex) {
|
||||||
return apply(new PlayUntilPosition(tag, windowIndex, /* positionMs= */ 0));
|
return apply(new PlayUntilPosition(tag, mediaItemIndex, /* positionMs= */ 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -323,16 +324,16 @@ public final class ActionSchedule {
|
||||||
/**
|
/**
|
||||||
* Schedules a set media items action to be executed.
|
* Schedules a set media items action to be executed.
|
||||||
*
|
*
|
||||||
* @param windowIndex The window index to start playback from or {@link C#INDEX_UNSET} if the
|
* @param mediaItemIndex The media item index to start playback from or {@link C#INDEX_UNSET} if
|
||||||
* playback position should not be reset.
|
* the playback position should not be reset.
|
||||||
* @param positionMs The position in milliseconds from where playback should start. If {@link
|
* @param positionMs The position in milliseconds from where playback should start. If {@link
|
||||||
* C#TIME_UNSET} is passed the default position is used. In any case, if {@code windowIndex}
|
* C#TIME_UNSET} is passed the default position is used. In any case, if {@code
|
||||||
* is set to {@link C#INDEX_UNSET} the position is not reset at all and this parameter is
|
* mediaItemIndex} is set to {@link C#INDEX_UNSET} the position is not reset at all and this
|
||||||
* ignored.
|
* parameter is ignored.
|
||||||
* @return The builder, for convenience.
|
* @return The builder, for convenience.
|
||||||
*/
|
*/
|
||||||
public Builder setMediaSources(int windowIndex, long positionMs, MediaSource... sources) {
|
public Builder setMediaSources(int mediaItemIndex, long positionMs, MediaSource... sources) {
|
||||||
return apply(new Action.SetMediaItems(tag, windowIndex, positionMs, sources));
|
return apply(new Action.SetMediaItems(tag, mediaItemIndex, positionMs, sources));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -354,7 +355,10 @@ public final class ActionSchedule {
|
||||||
public Builder setMediaSources(MediaSource... mediaSources) {
|
public Builder setMediaSources(MediaSource... mediaSources) {
|
||||||
return apply(
|
return apply(
|
||||||
new Action.SetMediaItems(
|
new Action.SetMediaItems(
|
||||||
tag, /* windowIndex= */ C.INDEX_UNSET, /* positionMs= */ C.TIME_UNSET, mediaSources));
|
tag,
|
||||||
|
/* mediaItemIndex= */ C.INDEX_UNSET,
|
||||||
|
/* positionMs= */ C.TIME_UNSET,
|
||||||
|
mediaSources));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Schedules a add media items action to be executed.
|
* Schedules a add media items action to be executed.
|
||||||
|
|
@ -447,8 +451,8 @@ public final class ActionSchedule {
|
||||||
/**
|
/**
|
||||||
* Schedules sending a {@link PlayerMessage}.
|
* Schedules sending a {@link PlayerMessage}.
|
||||||
*
|
*
|
||||||
* @param positionMs The position in the current window at which the message should be sent, in
|
* @param positionMs The position in the current media item at which the message should be sent,
|
||||||
* milliseconds.
|
* in milliseconds.
|
||||||
* @return The builder, for convenience.
|
* @return The builder, for convenience.
|
||||||
*/
|
*/
|
||||||
public Builder sendMessage(Target target, long positionMs) {
|
public Builder sendMessage(Target target, long positionMs) {
|
||||||
|
|
@ -459,27 +463,28 @@ public final class ActionSchedule {
|
||||||
* Schedules sending a {@link PlayerMessage}.
|
* Schedules sending a {@link PlayerMessage}.
|
||||||
*
|
*
|
||||||
* @param target A message target.
|
* @param target A message target.
|
||||||
* @param windowIndex The window index at which the message should be sent.
|
* @param mediaItemIndex The media item index at which the message should be sent.
|
||||||
* @param positionMs The position at which the message should be sent, in milliseconds.
|
* @param positionMs The position at which the message should be sent, in milliseconds.
|
||||||
* @return The builder, for convenience.
|
* @return The builder, for convenience.
|
||||||
*/
|
*/
|
||||||
public Builder sendMessage(Target target, int windowIndex, long positionMs) {
|
public Builder sendMessage(Target target, int mediaItemIndex, long positionMs) {
|
||||||
return apply(
|
return apply(
|
||||||
new SendMessages(tag, target, windowIndex, positionMs, /* deleteAfterDelivery= */ true));
|
new SendMessages(
|
||||||
|
tag, target, mediaItemIndex, positionMs, /* deleteAfterDelivery= */ true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedules to send a {@link PlayerMessage}.
|
* Schedules to send a {@link PlayerMessage}.
|
||||||
*
|
*
|
||||||
* @param target A message target.
|
* @param target A message target.
|
||||||
* @param windowIndex The window index at which the message should be sent.
|
* @param mediaItemIndex The media item index at which the message should be sent.
|
||||||
* @param positionMs The position at which the message should be sent, in milliseconds.
|
* @param positionMs The position at which the message should be sent, in milliseconds.
|
||||||
* @param deleteAfterDelivery Whether the message will be deleted after delivery.
|
* @param deleteAfterDelivery Whether the message will be deleted after delivery.
|
||||||
* @return The builder, for convenience.
|
* @return The builder, for convenience.
|
||||||
*/
|
*/
|
||||||
public Builder sendMessage(
|
public Builder sendMessage(
|
||||||
Target target, int windowIndex, long positionMs, boolean deleteAfterDelivery) {
|
Target target, int mediaItemIndex, long positionMs, boolean deleteAfterDelivery) {
|
||||||
return apply(new SendMessages(tag, target, windowIndex, positionMs, deleteAfterDelivery));
|
return apply(new SendMessages(tag, target, mediaItemIndex, positionMs, deleteAfterDelivery));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
|
||||||
private AnalyticsListener analyticsListener;
|
private AnalyticsListener analyticsListener;
|
||||||
private Integer expectedPlayerEndedCount;
|
private Integer expectedPlayerEndedCount;
|
||||||
private boolean pauseAtEndOfMediaItems;
|
private boolean pauseAtEndOfMediaItems;
|
||||||
private int initialWindowIndex;
|
private int initialMediaItemIndex;
|
||||||
private long initialPositionMs;
|
private long initialPositionMs;
|
||||||
private boolean skipSettingMediaSources;
|
private boolean skipSettingMediaSources;
|
||||||
|
|
||||||
|
|
@ -93,7 +93,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
|
||||||
testPlayerBuilder = new TestExoPlayerBuilder(context);
|
testPlayerBuilder = new TestExoPlayerBuilder(context);
|
||||||
mediaSources = new ArrayList<>();
|
mediaSources = new ArrayList<>();
|
||||||
supportedFormats = new Format[] {VIDEO_FORMAT};
|
supportedFormats = new Format[] {VIDEO_FORMAT};
|
||||||
initialWindowIndex = C.INDEX_UNSET;
|
initialMediaItemIndex = C.INDEX_UNSET;
|
||||||
initialPositionMs = C.TIME_UNSET;
|
initialPositionMs = C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,12 +133,12 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
|
||||||
/**
|
/**
|
||||||
* Seeks before setting the media sources and preparing the player.
|
* Seeks before setting the media sources and preparing the player.
|
||||||
*
|
*
|
||||||
* @param windowIndex The window index to seek to.
|
* @param mediaItemIndex The media item index to seek to.
|
||||||
* @param positionMs The position in milliseconds to seek to.
|
* @param positionMs The position in milliseconds to seek to.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder initialSeek(int windowIndex, long positionMs) {
|
public Builder initialSeek(int mediaItemIndex, long positionMs) {
|
||||||
this.initialWindowIndex = windowIndex;
|
this.initialMediaItemIndex = mediaItemIndex;
|
||||||
this.initialPositionMs = positionMs;
|
this.initialPositionMs = positionMs;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -343,7 +343,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
|
||||||
testPlayerBuilder,
|
testPlayerBuilder,
|
||||||
mediaSources,
|
mediaSources,
|
||||||
skipSettingMediaSources,
|
skipSettingMediaSources,
|
||||||
initialWindowIndex,
|
initialMediaItemIndex,
|
||||||
initialPositionMs,
|
initialPositionMs,
|
||||||
surface,
|
surface,
|
||||||
actionSchedule,
|
actionSchedule,
|
||||||
|
|
@ -357,7 +357,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
|
||||||
private final TestExoPlayerBuilder playerBuilder;
|
private final TestExoPlayerBuilder playerBuilder;
|
||||||
private final List<MediaSource> mediaSources;
|
private final List<MediaSource> mediaSources;
|
||||||
private final boolean skipSettingMediaSources;
|
private final boolean skipSettingMediaSources;
|
||||||
private final int initialWindowIndex;
|
private final int initialMediaItemIndex;
|
||||||
private final long initialPositionMs;
|
private final long initialPositionMs;
|
||||||
@Nullable private final Surface surface;
|
@Nullable private final Surface surface;
|
||||||
@Nullable private final ActionSchedule actionSchedule;
|
@Nullable private final ActionSchedule actionSchedule;
|
||||||
|
|
@ -386,7 +386,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
|
||||||
TestExoPlayerBuilder playerBuilder,
|
TestExoPlayerBuilder playerBuilder,
|
||||||
List<MediaSource> mediaSources,
|
List<MediaSource> mediaSources,
|
||||||
boolean skipSettingMediaSources,
|
boolean skipSettingMediaSources,
|
||||||
int initialWindowIndex,
|
int initialMediaItemIndex,
|
||||||
long initialPositionMs,
|
long initialPositionMs,
|
||||||
@Nullable Surface surface,
|
@Nullable Surface surface,
|
||||||
@Nullable ActionSchedule actionSchedule,
|
@Nullable ActionSchedule actionSchedule,
|
||||||
|
|
@ -397,7 +397,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
|
||||||
this.playerBuilder = playerBuilder;
|
this.playerBuilder = playerBuilder;
|
||||||
this.mediaSources = mediaSources;
|
this.mediaSources = mediaSources;
|
||||||
this.skipSettingMediaSources = skipSettingMediaSources;
|
this.skipSettingMediaSources = skipSettingMediaSources;
|
||||||
this.initialWindowIndex = initialWindowIndex;
|
this.initialMediaItemIndex = initialMediaItemIndex;
|
||||||
this.initialPositionMs = initialPositionMs;
|
this.initialPositionMs = initialPositionMs;
|
||||||
this.surface = surface;
|
this.surface = surface;
|
||||||
this.actionSchedule = actionSchedule;
|
this.actionSchedule = actionSchedule;
|
||||||
|
|
@ -466,8 +466,8 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
|
||||||
handler,
|
handler,
|
||||||
/* callback= */ ExoPlayerTestRunner.this);
|
/* callback= */ ExoPlayerTestRunner.this);
|
||||||
}
|
}
|
||||||
if (initialWindowIndex != C.INDEX_UNSET) {
|
if (initialMediaItemIndex != C.INDEX_UNSET) {
|
||||||
player.seekTo(initialWindowIndex, initialPositionMs);
|
player.seekTo(initialMediaItemIndex, initialPositionMs);
|
||||||
}
|
}
|
||||||
if (!skipSettingMediaSources) {
|
if (!skipSettingMediaSources) {
|
||||||
player.setMediaSources(mediaSources, /* resetPosition= */ false);
|
player.setMediaSources(mediaSources, /* resetPosition= */ false);
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ public class StubExoPlayer extends StubPlayer implements ExoPlayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMediaSources(
|
public void setMediaSources(
|
||||||
List<MediaSource> mediaSources, int startWindowIndex, long startPositionMs) {
|
List<MediaSource> mediaSources, int startMediaItemIndex, long startPositionMs) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue