Commit 8c5af10a by olly Committed by Oliver Woodman

Don't pass INDEX_UNSET to ExoPlayer seek methods

It's not valid, and will cause IllegalSeekPositionException to be thrown

PiperOrigin-RevId: 327301325
parent ee743870
......@@ -294,7 +294,7 @@ import java.util.List;
@Nullable
public androidx.media2.common.MediaItem getCurrentMediaItem() {
int index = getCurrentMediaItemIndex();
return (index != C.INDEX_UNSET) ? media2Playlist.get(index) : null;
return index == C.INDEX_UNSET ? null : media2Playlist.get(index);
}
public boolean prepare() {
......@@ -307,9 +307,9 @@ import java.util.List;
public boolean play() {
if (player.getPlaybackState() == Player.STATE_ENDED) {
int currentWindowIndex = getCurrentMediaItemIndex();
boolean seekHandled =
controlDispatcher.dispatchSeekTo(player, currentWindowIndex, /* positionMs= */ 0);
controlDispatcher.dispatchSeekTo(
player, player.getCurrentWindowIndex(), /* positionMs= */ 0);
if (!seekHandled) {
return false;
}
......@@ -332,8 +332,7 @@ import java.util.List;
}
public boolean seekTo(long position) {
int currentWindowIndex = getCurrentMediaItemIndex();
return controlDispatcher.dispatchSeekTo(player, currentWindowIndex, position);
return controlDispatcher.dispatchSeekTo(player, player.getCurrentWindowIndex(), position);
}
public long getCurrentPosition() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment