Commit d0fc83ed by bachinger Committed by Oliver Woodman

Playlist API: move media item based API to Player

This moves the playlist API methods to the Player interface. Implementation is moved from ExoPlayerImpl to BasePlayer where possible.

Further the CastPlayer is changed to implement the Player interface. Proper migration of the Playermanager to not use the ConcatenatingMediaSource anymore follows in a separate, future CL.

PiperOrigin-RevId: 302937779
parent 4ff04696
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
floating point audio without adjustment, pass `enableFloatOutput=true` floating point audio without adjustment, pass `enableFloatOutput=true`
to the `DefaultAudioSink` constructor to the `DefaultAudioSink` constructor
([#7134](https://github.com/google/ExoPlayer/issues/7134)). ([#7134](https://github.com/google/ExoPlayer/issues/7134)).
* Add media item based playlist API to Player.
* Text: * Text:
* Parse `<ruby>` and `<rt>` tags in WebVTT subtitles (rendering is coming * Parse `<ruby>` and `<rt>` tags in WebVTT subtitles (rendering is coming
later). later).
...@@ -129,6 +130,8 @@ ...@@ -129,6 +130,8 @@
([#6922](https://github.com/google/ExoPlayer/pull/6922)). ([#6922](https://github.com/google/ExoPlayer/pull/6922)).
* The demo app startup selected item is the last played one. * The demo app startup selected item is the last played one.
* Add support for x86_64 for the ffmpeg extension. * Add support for x86_64 for the ffmpeg extension.
* Cast extension: Implement playlist API and deprecate the old queue
manipulation API.
### 2.11.3 (2020-02-19) ### ### 2.11.3 (2020-02-19) ###
......
...@@ -27,10 +27,7 @@ import com.google.android.exoplayer2.Player.EventListener; ...@@ -27,10 +27,7 @@ import com.google.android.exoplayer2.Player.EventListener;
import com.google.android.exoplayer2.Player.TimelineChangeReason; import com.google.android.exoplayer2.Player.TimelineChangeReason;
import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.ext.cast.CastPlayer; import com.google.android.exoplayer2.ext.cast.CastPlayer;
import com.google.android.exoplayer2.ext.cast.DefaultMediaItemConverter;
import com.google.android.exoplayer2.ext.cast.MediaItemConverter;
import com.google.android.exoplayer2.ext.cast.SessionAvailabilityListener; import com.google.android.exoplayer2.ext.cast.SessionAvailabilityListener;
import com.google.android.exoplayer2.source.ConcatenatingMediaSource; import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory; import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
...@@ -41,7 +38,6 @@ import com.google.android.exoplayer2.trackselection.TrackSelectionArray; ...@@ -41,7 +38,6 @@ import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.ui.PlayerControlView; import com.google.android.exoplayer2.ui.PlayerControlView;
import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.gms.cast.MediaQueueItem;
import com.google.android.gms.cast.framework.CastContext; import com.google.android.gms.cast.framework.CastContext;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -75,7 +71,6 @@ import java.util.ArrayList; ...@@ -75,7 +71,6 @@ import java.util.ArrayList;
private final ArrayList<MediaItem> mediaQueue; private final ArrayList<MediaItem> mediaQueue;
private final Listener listener; private final Listener listener;
private final ConcatenatingMediaSource concatenatingMediaSource; private final ConcatenatingMediaSource concatenatingMediaSource;
private final MediaItemConverter mediaItemConverter;
private TrackGroupArray lastSeenTrackGroupArray; private TrackGroupArray lastSeenTrackGroupArray;
private int currentItemIndex; private int currentItemIndex;
...@@ -102,7 +97,6 @@ import java.util.ArrayList; ...@@ -102,7 +97,6 @@ import java.util.ArrayList;
mediaQueue = new ArrayList<>(); mediaQueue = new ArrayList<>();
currentItemIndex = C.INDEX_UNSET; currentItemIndex = C.INDEX_UNSET;
concatenatingMediaSource = new ConcatenatingMediaSource(); concatenatingMediaSource = new ConcatenatingMediaSource();
mediaItemConverter = new DefaultMediaItemConverter();
trackSelector = new DefaultTrackSelector(context); trackSelector = new DefaultTrackSelector(context);
exoPlayer = new SimpleExoPlayer.Builder(context).setTrackSelector(trackSelector).build(); exoPlayer = new SimpleExoPlayer.Builder(context).setTrackSelector(trackSelector).build();
...@@ -143,7 +137,7 @@ import java.util.ArrayList; ...@@ -143,7 +137,7 @@ import java.util.ArrayList;
mediaQueue.add(item); mediaQueue.add(item);
concatenatingMediaSource.addMediaSource(defaultMediaSourceFactory.createMediaSource(item)); concatenatingMediaSource.addMediaSource(defaultMediaSourceFactory.createMediaSource(item));
if (currentPlayer == castPlayer) { if (currentPlayer == castPlayer) {
castPlayer.addItems(mediaItemConverter.toMediaQueueItem(item)); castPlayer.addMediaItem(item);
} }
} }
...@@ -180,7 +174,7 @@ import java.util.ArrayList; ...@@ -180,7 +174,7 @@ import java.util.ArrayList;
if (castTimeline.getPeriodCount() <= itemIndex) { if (castTimeline.getPeriodCount() <= itemIndex) {
return false; return false;
} }
castPlayer.removeItem((int) castTimeline.getPeriod(itemIndex, new Period()).id); castPlayer.removeMediaItem(itemIndex);
} }
} }
mediaQueue.remove(itemIndex); mediaQueue.remove(itemIndex);
...@@ -196,34 +190,33 @@ import java.util.ArrayList; ...@@ -196,34 +190,33 @@ import java.util.ArrayList;
* Moves an item within the queue. * Moves an item within the queue.
* *
* @param item The item to move. * @param item The item to move.
* @param toIndex The target index of the item in the queue. * @param newIndex The target index of the item in the queue.
* @return Whether the item move was successful. * @return Whether the item move was successful.
*/ */
public boolean moveItem(MediaItem item, int toIndex) { public boolean moveItem(MediaItem item, int newIndex) {
int fromIndex = mediaQueue.indexOf(item); int fromIndex = mediaQueue.indexOf(item);
if (fromIndex == -1) { if (fromIndex == -1) {
return false; return false;
} }
// Player update. // Player update.
concatenatingMediaSource.moveMediaSource(fromIndex, toIndex); concatenatingMediaSource.moveMediaSource(fromIndex, newIndex);
if (currentPlayer == castPlayer && castPlayer.getPlaybackState() != Player.STATE_IDLE) { if (currentPlayer == castPlayer && castPlayer.getPlaybackState() != Player.STATE_IDLE) {
Timeline castTimeline = castPlayer.getCurrentTimeline(); Timeline castTimeline = castPlayer.getCurrentTimeline();
int periodCount = castTimeline.getPeriodCount(); int periodCount = castTimeline.getPeriodCount();
if (periodCount <= fromIndex || periodCount <= toIndex) { if (periodCount <= fromIndex || periodCount <= newIndex) {
return false; return false;
} }
int elementId = (int) castTimeline.getPeriod(fromIndex, new Period()).id; castPlayer.moveMediaItem(fromIndex, newIndex);
castPlayer.moveItem(elementId, toIndex);
} }
mediaQueue.add(toIndex, mediaQueue.remove(fromIndex)); mediaQueue.add(newIndex, mediaQueue.remove(fromIndex));
// Index update. // Index update.
if (fromIndex == currentItemIndex) { if (fromIndex == currentItemIndex) {
maybeSetCurrentItemAndNotify(toIndex); maybeSetCurrentItemAndNotify(newIndex);
} else if (fromIndex < currentItemIndex && toIndex >= currentItemIndex) { } else if (fromIndex < currentItemIndex && newIndex >= currentItemIndex) {
maybeSetCurrentItemAndNotify(currentItemIndex - 1); maybeSetCurrentItemAndNotify(currentItemIndex - 1);
} else if (fromIndex > currentItemIndex && toIndex <= currentItemIndex) { } else if (fromIndex > currentItemIndex && newIndex <= currentItemIndex) {
maybeSetCurrentItemAndNotify(currentItemIndex + 1); maybeSetCurrentItemAndNotify(currentItemIndex + 1);
} }
...@@ -353,7 +346,8 @@ import java.util.ArrayList; ...@@ -353,7 +346,8 @@ import java.util.ArrayList;
// Media queue management. // Media queue management.
if (currentPlayer == exoPlayer) { if (currentPlayer == exoPlayer) {
exoPlayer.prepare(concatenatingMediaSource); exoPlayer.setMediaSource(concatenatingMediaSource, /* resetPosition= */ true);
exoPlayer.prepare();
} }
// Playback transition. // Playback transition.
...@@ -372,11 +366,7 @@ import java.util.ArrayList; ...@@ -372,11 +366,7 @@ import java.util.ArrayList;
private void setCurrentItem(int itemIndex, long positionMs, boolean playWhenReady) { private void setCurrentItem(int itemIndex, long positionMs, boolean playWhenReady) {
maybeSetCurrentItemAndNotify(itemIndex); maybeSetCurrentItemAndNotify(itemIndex);
if (currentPlayer == castPlayer && castPlayer.getCurrentTimeline().isEmpty()) { if (currentPlayer == castPlayer && castPlayer.getCurrentTimeline().isEmpty()) {
MediaQueueItem[] items = new MediaQueueItem[mediaQueue.size()]; castPlayer.setMediaItems(mediaQueue, itemIndex, positionMs);
for (int i = 0; i < items.length; i++) {
items[i] = mediaItemConverter.toMediaQueueItem(mediaQueue.get(i));
}
castPlayer.loadItems(items, itemIndex, positionMs, Player.REPEAT_MODE_OFF);
} else { } else {
currentPlayer.seekTo(itemIndex, positionMs); currentPlayer.seekTo(itemIndex, positionMs);
currentPlayer.setPlayWhenReady(playWhenReady); currentPlayer.setPlayWhenReady(playWhenReady);
......
...@@ -17,6 +17,8 @@ package com.google.android.exoplayer2; ...@@ -17,6 +17,8 @@ package com.google.android.exoplayer2;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.util.Collections;
import java.util.List;
/** Abstract base {@link Player} which implements common implementation independent methods. */ /** Abstract base {@link Player} which implements common implementation independent methods. */
public abstract class BasePlayer implements Player { public abstract class BasePlayer implements Player {
...@@ -28,6 +30,54 @@ public abstract class BasePlayer implements Player { ...@@ -28,6 +30,54 @@ public abstract class BasePlayer implements Player {
} }
@Override @Override
public void setMediaItem(MediaItem mediaItem) {
setMediaItems(Collections.singletonList(mediaItem));
}
@Override
public void setMediaItem(MediaItem mediaItem, long startPositionMs) {
setMediaItems(Collections.singletonList(mediaItem), /* startWindowIndex= */ 0, startPositionMs);
}
@Override
public void setMediaItem(MediaItem mediaItem, boolean resetPosition) {
setMediaItems(Collections.singletonList(mediaItem), resetPosition);
}
@Override
public void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition) {
setMediaItems(
mediaItems, /* startWindowIndex= */ C.INDEX_UNSET, /* startPositionMs= */ C.TIME_UNSET);
}
@Override
public void setMediaItems(List<MediaItem> mediaItems) {
setMediaItems(mediaItems, /* resetPosition= */ true);
}
@Override
public void addMediaItem(int index, MediaItem mediaItem) {
addMediaItems(index, Collections.singletonList(mediaItem));
}
@Override
public void addMediaItem(MediaItem mediaItem) {
addMediaItems(Collections.singletonList(mediaItem));
}
@Override
public void moveMediaItem(int currentIndex, int newIndex) {
if (currentIndex != newIndex) {
moveMediaItems(/* fromIndex= */ currentIndex, /* toIndex= */ currentIndex + 1, newIndex);
}
}
@Override
public void removeMediaItem(int index) {
removeMediaItems(/* fromIndex= */ index, /* toIndex= */ index + 1);
}
@Override
public final void play() { public final void play() {
setPlayWhenReady(true); setPlayWhenReady(true);
} }
......
...@@ -410,9 +410,6 @@ public interface ExoPlayer extends Player { ...@@ -410,9 +410,6 @@ public interface ExoPlayer extends Player {
@Deprecated @Deprecated
void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState); void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState);
/** Prepares the player. */
void prepare();
/** /**
* Clears the playlist, adds the specified {@link MediaSource MediaSources} and resets the * Clears the playlist, adds the specified {@link MediaSource MediaSources} and resets the
* position to the default position. * position to the default position.
...@@ -501,131 +498,6 @@ public interface ExoPlayer extends Player { ...@@ -501,131 +498,6 @@ public interface ExoPlayer extends Player {
void addMediaSources(int index, List<MediaSource> mediaSources); void addMediaSources(int index, List<MediaSource> mediaSources);
/** /**
* Clears the playlist, adds the specified {@link MediaItem MediaItems} and resets the position to
* the default position.
*
* @param mediaItems The new {@link MediaItem MediaItems}.
*/
void setMediaItems(List<MediaItem> mediaItems);
/**
* Clears the playlist and adds the specified {@link MediaItem MediaItems}.
*
* @param mediaItems The new {@link MediaItem MediaItems}.
* @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
* by {@link #getCurrentWindowIndex()} and {@link #getCurrentPosition()}.
*/
void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition);
/**
* Clears the playlist and adds the specified {@link MediaItem MediaItems}.
*
* @param mediaItems The new {@link MediaItem MediaItems}.
* @param startWindowIndex The window index to start playback from. If {@link C#INDEX_UNSET} is
* passed, the current position is not reset.
* @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
* {@code startWindowIndex} is set to {@link C#INDEX_UNSET}, this parameter is ignored and the
* position is not reset at all.
*/
void setMediaItems(List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs);
/**
* Clears the playlist, adds the specified {@link MediaItem} and resets the position to the
* default position.
*
* @param mediaItem The new {@link MediaItem}.
*/
void setMediaItem(MediaItem mediaItem);
/**
* Clears the playlist and adds the specified {@link MediaItem}.
*
* @param mediaItem The new {@link MediaItem}.
* @param startPositionMs The position in milliseconds to start playback from.
*/
void setMediaItem(MediaItem mediaItem, long startPositionMs);
/**
* Clears the playlist and adds the specified {@link MediaItem}.
*
* @param mediaItem The new {@link MediaItem}.
* @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()}
* and {@link #getCurrentPosition()}.
*/
void setMediaItem(MediaItem mediaItem, boolean resetPosition);
/**
* Adds a media item to the end of the playlist.
*
* @param mediaItem The {@link MediaItem} to add.
*/
void addMediaItem(MediaItem mediaItem);
/**
* Adds a media item at the given index of the playlist.
*
* @param index The index at which to add the item.
* @param mediaItem The {@link MediaItem} to add.
*/
void addMediaItem(int index, MediaItem mediaItem);
/**
* Adds a list of media items to the end of the playlist.
*
* @param mediaItems The {@link MediaItem MediaItems} to add.
*/
void addMediaItems(List<MediaItem> mediaItems);
/**
* Adds a list of media items at the given index of the playlist.
*
* @param index The index at which to add the media items.
* @param mediaItems The {@link MediaItem MediaItems} to add.
*/
void addMediaItems(int index, List<MediaItem> mediaItems);
/**
* Moves the media item at the current index to the new index.
*
* @param currentIndex The current index of the media item to move.
* @param newIndex The new index of the media item. If the new index is larger than the size of
* the playlist the item is moved to the end of the playlist.
*/
void moveMediaItem(int currentIndex, int newIndex);
/**
* Moves the media item range to the new index.
*
* @param fromIndex The start of the range to move.
* @param toIndex The first item not to be included in the range (exclusive).
* @param newIndex The new index of the first media item of the range. If the new index is larger
* than the size of the remaining playlist after removing the range, the range is moved to the
* end of the playlist.
*/
void moveMediaItems(int fromIndex, int toIndex, int newIndex);
/**
* Removes the media item at the given index of the playlist.
*
* @param index The index at which to remove the media item.
*/
void removeMediaItem(int index);
/**
* Removes a range of media items from the playlist.
*
* @param fromIndex The index at which to start removing media items.
* @param toIndex The index of the first item to be kept (exclusive).
*/
void removeMediaItems(int fromIndex, int toIndex);
/** Clears the playlist. */
void clearMediaItems();
/**
* Sets the shuffle order. * Sets the shuffle order.
* *
* @param shuffleOrder The shuffle order. * @param shuffleOrder The shuffle order.
......
...@@ -322,31 +322,6 @@ import java.util.concurrent.TimeoutException; ...@@ -322,31 +322,6 @@ import java.util.concurrent.TimeoutException;
} }
@Override @Override
public void setMediaItem(MediaItem mediaItem) {
setMediaItems(Collections.singletonList(mediaItem));
}
@Override
public void setMediaItem(MediaItem mediaItem, long startPositionMs) {
setMediaItems(Collections.singletonList(mediaItem), /* startWindowIndex= */ 0, startPositionMs);
}
@Override
public void setMediaItem(MediaItem mediaItem, boolean resetPosition) {
setMediaItems(Collections.singletonList(mediaItem), resetPosition);
}
@Override
public void setMediaItems(List<MediaItem> mediaItems) {
setMediaItems(mediaItems, /* resetPosition= */ true);
}
@Override
public void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition) {
setMediaSources(createMediaSources(mediaItems), resetPosition);
}
@Override
public void setMediaItems( public void setMediaItems(
List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs) { List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs) {
setMediaSources(createMediaSources(mediaItems), startWindowIndex, startPositionMs); setMediaSources(createMediaSources(mediaItems), startWindowIndex, startPositionMs);
...@@ -390,16 +365,6 @@ import java.util.concurrent.TimeoutException; ...@@ -390,16 +365,6 @@ import java.util.concurrent.TimeoutException;
} }
@Override @Override
public void addMediaItem(int index, MediaItem mediaItem) {
addMediaItems(index, Collections.singletonList(mediaItem));
}
@Override
public void addMediaItem(MediaItem mediaItem) {
addMediaItems(Collections.singletonList(mediaItem));
}
@Override
public void addMediaItems(List<MediaItem> mediaItems) { public void addMediaItems(List<MediaItem> mediaItems) {
addMediaItems(/* index= */ mediaSourceHolders.size(), mediaItems); addMediaItems(/* index= */ mediaSourceHolders.size(), mediaItems);
} }
...@@ -445,23 +410,12 @@ import java.util.concurrent.TimeoutException; ...@@ -445,23 +410,12 @@ import java.util.concurrent.TimeoutException;
} }
@Override @Override
public void removeMediaItem(int index) {
removeMediaItemsInternal(/* fromIndex= */ index, /* toIndex= */ index + 1);
}
@Override
public void removeMediaItems(int fromIndex, int toIndex) { public void removeMediaItems(int fromIndex, int toIndex) {
Assertions.checkArgument(toIndex > fromIndex); Assertions.checkArgument(toIndex > fromIndex);
removeMediaItemsInternal(fromIndex, toIndex); removeMediaItemsInternal(fromIndex, toIndex);
} }
@Override @Override
public void moveMediaItem(int currentIndex, int newIndex) {
Assertions.checkArgument(currentIndex != newIndex);
moveMediaItems(/* fromIndex= */ currentIndex, /* toIndex= */ currentIndex + 1, newIndex);
}
@Override
public void moveMediaItems(int fromIndex, int toIndex, int newFromIndex) { public void moveMediaItems(int fromIndex, int toIndex, int newFromIndex) {
Assertions.checkArgument( Assertions.checkArgument(
fromIndex >= 0 fromIndex >= 0
......
...@@ -39,6 +39,7 @@ import com.google.android.exoplayer2.video.spherical.CameraMotionListener; ...@@ -39,6 +39,7 @@ import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.util.List;
/** /**
* A media player interface defining traditional high-level functionality, such as the ability to * A media player interface defining traditional high-level functionality, such as the ability to
...@@ -755,6 +756,134 @@ public interface Player { ...@@ -755,6 +756,134 @@ public interface Player {
void removeListener(EventListener listener); void removeListener(EventListener listener);
/** /**
* Clears the playlist, adds the specified {@link MediaItem MediaItems} and resets the position to
* the default position.
*
* @param mediaItems The new {@link MediaItem MediaItems}.
*/
void setMediaItems(List<MediaItem> mediaItems);
/**
* Clears the playlist and adds the specified {@link MediaItem MediaItems}.
*
* @param mediaItems The new {@link MediaItem MediaItems}.
* @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
* by {@link #getCurrentWindowIndex()} and {@link #getCurrentPosition()}.
*/
void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition);
/**
* Clears the playlist and adds the specified {@link MediaItem MediaItems}.
*
* @param mediaItems The new {@link MediaItem MediaItems}.
* @param startWindowIndex The window index to start playback from. If {@link C#INDEX_UNSET} is
* passed, the current position is not reset.
* @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
* {@code startWindowIndex} is set to {@link C#INDEX_UNSET}, this parameter is ignored and the
* position is not reset at all.
*/
void setMediaItems(List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs);
/**
* Clears the playlist, adds the specified {@link MediaItem} and resets the position to the
* default position.
*
* @param mediaItem The new {@link MediaItem}.
*/
void setMediaItem(MediaItem mediaItem);
/**
* Clears the playlist and adds the specified {@link MediaItem}.
*
* @param mediaItem The new {@link MediaItem}.
* @param startPositionMs The position in milliseconds to start playback from.
*/
void setMediaItem(MediaItem mediaItem, long startPositionMs);
/**
* Clears the playlist and adds the specified {@link MediaItem}.
*
* @param mediaItem The new {@link MediaItem}.
* @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()}
* and {@link #getCurrentPosition()}.
*/
void setMediaItem(MediaItem mediaItem, boolean resetPosition);
/**
* Adds a media item to the end of the playlist.
*
* @param mediaItem The {@link MediaItem} to add.
*/
void addMediaItem(MediaItem mediaItem);
/**
* Adds a media item at the given index of the playlist.
*
* @param index The index at which to add the item.
* @param mediaItem The {@link MediaItem} to add.
*/
void addMediaItem(int index, MediaItem mediaItem);
/**
* Adds a list of media items to the end of the playlist.
*
* @param mediaItems The {@link MediaItem MediaItems} to add.
*/
void addMediaItems(List<MediaItem> mediaItems);
/**
* Adds a list of media items at the given index of the playlist.
*
* @param index The index at which to add the media items.
* @param mediaItems The {@link MediaItem MediaItems} to add.
*/
void addMediaItems(int index, List<MediaItem> mediaItems);
/**
* Moves the media item at the current index to the new index.
*
* @param currentIndex The current index of the media item to move.
* @param newIndex The new index of the media item. If the new index is larger than the size of
* the playlist the item is moved to the end of the playlist.
*/
void moveMediaItem(int currentIndex, int newIndex);
/**
* Moves the media item range to the new index.
*
* @param fromIndex The start of the range to move.
* @param toIndex The first item not to be included in the range (exclusive).
* @param newIndex The new index of the first media item of the range. If the new index is larger
* than the size of the remaining playlist after removing the range, the range is moved to the
* end of the playlist.
*/
void moveMediaItems(int fromIndex, int toIndex, int newIndex);
/**
* Removes the media item at the given index of the playlist.
*
* @param index The index at which to remove the media item.
*/
void removeMediaItem(int index);
/**
* Removes a range of media items from the playlist.
*
* @param fromIndex The index at which to start removing media items.
* @param toIndex The index of the first item to be kept (exclusive).
*/
void removeMediaItems(int fromIndex, int toIndex);
/** Clears the playlist. */
void clearMediaItems();
/** Prepares the player. */
void prepare();
/**
* Returns the current {@link State playback state} of the player. * Returns the current {@link State playback state} of the player.
* *
* @return The current {@link State playback state}. * @return The current {@link State playback state}.
......
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