make removeMediaItem return void

PiperOrigin-RevId: 286551438
This commit is contained in:
bachinger 2019-12-20 11:24:26 +00:00 committed by Oliver Woodman
parent 8c0f22c99c
commit 06ffd23cdc
4 changed files with 8 additions and 14 deletions

View File

@ -486,10 +486,8 @@ public interface ExoPlayer extends Player {
* Removes the media item at the given index of the playlist. * Removes the media item at the given index of the playlist.
* *
* @param index The index at which to remove the media item. * @param index The index at which to remove the media item.
* @return The removed {@link MediaSource} or null if no item exists at the given index.
*/ */
@Nullable void removeMediaItem(int index);
MediaSource removeMediaItem(int index);
/** /**
* Removes a range of media items from the playlist. * Removes a range of media items from the playlist.

View File

@ -368,10 +368,8 @@ import java.util.concurrent.TimeoutException;
} }
@Override @Override
public MediaSource removeMediaItem(int index) { public void removeMediaItem(int index) {
List<Playlist.MediaSourceHolder> mediaSourceHolders = removeMediaItemsInternal(/* fromIndex= */ index, /* toIndex= */ index + 1);
removeMediaItemsInternal(/* fromIndex= */ index, /* toIndex= */ index + 1);
return mediaSourceHolders.isEmpty() ? null : mediaSourceHolders.get(0).mediaSource;
} }
@Override @Override
@ -956,7 +954,7 @@ import java.util.concurrent.TimeoutException;
return holders; return holders;
} }
private List<Playlist.MediaSourceHolder> removeMediaItemsInternal(int fromIndex, int toIndex) { private void removeMediaItemsInternal(int fromIndex, int toIndex) {
Assertions.checkArgument( Assertions.checkArgument(
fromIndex >= 0 && toIndex >= fromIndex && toIndex <= mediaSourceHolders.size()); fromIndex >= 0 && toIndex >= fromIndex && toIndex <= mediaSourceHolders.size());
int currentWindowIndex = getCurrentWindowIndex(); int currentWindowIndex = getCurrentWindowIndex();
@ -965,8 +963,7 @@ import java.util.concurrent.TimeoutException;
Timeline oldTimeline = getCurrentTimeline(); Timeline oldTimeline = getCurrentTimeline();
int currentMediaSourceCount = mediaSourceHolders.size(); int currentMediaSourceCount = mediaSourceHolders.size();
pendingOperationAcks++; pendingOperationAcks++;
List<Playlist.MediaSourceHolder> removedHolders = removeMediaSourceHolders(fromIndex, /* toIndexExclusive= */ toIndex);
removeMediaSourceHolders(fromIndex, /* toIndexExclusive= */ toIndex);
Timeline timeline = Timeline timeline =
maskTimelineAndWindowIndex(currentWindowIndex, currentPositionMs, oldTimeline); maskTimelineAndWindowIndex(currentWindowIndex, currentPositionMs, oldTimeline);
// Player transitions to STATE_ENDED if the current index is part of the removed tail. // Player transitions to STATE_ENDED if the current index is part of the removed tail.
@ -987,7 +984,6 @@ import java.util.concurrent.TimeoutException;
listener.onPlayerStateChanged(currentPlayWhenReady, STATE_ENDED); listener.onPlayerStateChanged(currentPlayWhenReady, STATE_ENDED);
} }
}); });
return removedHolders;
} }
private List<Playlist.MediaSourceHolder> removeMediaSourceHolders( private List<Playlist.MediaSourceHolder> removeMediaSourceHolders(

View File

@ -1290,9 +1290,9 @@ public class SimpleExoPlayer extends BasePlayer
} }
@Override @Override
public MediaSource removeMediaItem(int index) { public void removeMediaItem(int index) {
verifyApplicationThread(); verifyApplicationThread();
return player.removeMediaItem(index); player.removeMediaItem(index);
} }
@Override @Override

View File

@ -190,7 +190,7 @@ public abstract class StubExoPlayer extends BasePlayer implements ExoPlayer {
} }
@Override @Override
public MediaSource removeMediaItem(int index) { public void removeMediaItem(int index) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }