Package com.castlabs.android.player
Interface Playlist
-
- All Known Implementing Classes:
MultiControllerPlaylist
,PlaylistController
,SingleControllerPlaylist
public interface Playlist
Common Playlist interface.- Since:
- 4.2.5
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addItem(int position, PlayerConfig config)
Adds an item at the specified position in the playlist.void
addItem(PlayerConfig config)
Adds an item at the end of the playlist.PlayerConfig
getCurrentItem()
Returns the currently playing itemint
getCurrentItemIndex()
Returns current item indexList<PlayerConfig>
getPlaylist()
Returns the current Playlist as a List ofPlayerConfig
items.int
getSize()
Returns the number of Configs in the playlist.PlayerConfig
nextItem()
Advances playback to the next Playlist item.void
open(int startIndex, Parcelable... playerConfigs)
Start playback with the specified index and with an Array ofPlayerConfigs
orBundles
.void
open(int startIndex, List<? extends Parcelable> playerConfigs)
Start playback with the specified index and player configsvoid
open(Parcelable... playerConfigs)
Starts playback with an Array ofPlayerConfigs
orBundles
.void
open(List<? extends Parcelable> playerConfigs)
Starts playback with a List ofPlayerConfigs
orBundles
.PlayerConfig
playItem(int index)
Advances playback to the Playlist item specified by the index.PlayerConfig
previousItem()
Moves backwards in the Playlist.void
removeItem(PlayerConfig config)
Removes an item from the Playlistvoid
swap(PlayerConfig playerConfig1, PlayerConfig playerConfig2)
Interchanges two Playlist items.
-
-
-
Method Detail
-
addItem
void addItem(@NonNull PlayerConfig config)
Adds an item at the end of the playlist.- Parameters:
config
- item to add
-
addItem
void addItem(int position, @NonNull PlayerConfig config)
Adds an item at the specified position in the playlist.- Parameters:
position
- the position at which to add the item.config
- item to add- Throws:
IndexOutOfBoundsException
- if the position is negative or greater than the current Playlist size.
-
removeItem
void removeItem(@NonNull PlayerConfig config)
Removes an item from the Playlist- Parameters:
config
- item to remove
-
swap
void swap(@NonNull PlayerConfig playerConfig1, @NonNull PlayerConfig playerConfig2)
Interchanges two Playlist items. If any of such items is the currently playing item, playback won't be affected.- Parameters:
playerConfig1
- first item to swapplayerConfig2
- second item to swap
-
getCurrentItem
@Nullable PlayerConfig getCurrentItem()
Returns the currently playing item- Returns:
- the currently playing item
-
getPlaylist
List<PlayerConfig> getPlaylist()
Returns the current Playlist as a List ofPlayerConfig
items.- Returns:
- the current Playlist
-
getSize
int getSize()
Returns the number of Configs in the playlist.- Returns:
- number of Configs
-
getCurrentItemIndex
int getCurrentItemIndex()
Returns current item index- Returns:
- Current item index or
-1
otherwise
-
open
void open(@NonNull Parcelable... playerConfigs)
Starts playback with an Array ofPlayerConfigs
orBundles
.- Parameters:
playerConfigs
- array of PlayerConfigs or Bundles, each representing a Playlist item.
-
open
void open(int startIndex, @NonNull Parcelable... playerConfigs)
Start playback with the specified index and with an Array ofPlayerConfigs
orBundles
.- Parameters:
startIndex
- The index of the config to start playback withplayerConfigs
- The array of player configs to play
-
open
void open(@NonNull List<? extends Parcelable> playerConfigs)
Starts playback with a List ofPlayerConfigs
orBundles
.- Parameters:
playerConfigs
- list of PlayerConfigs, or Bundles each representing a Playlist item.
-
open
void open(int startIndex, @NonNull List<? extends Parcelable> playerConfigs)
Start playback with the specified index and player configs- Parameters:
startIndex
- The index of the config to start playback withplayerConfigs
- The list of player configs to play
-
nextItem
@Nullable PlayerConfig nextItem()
Advances playback to the next Playlist item.- Returns:
- the next item to play. If null, the end of the Playlist has been reached.
-
playItem
@Nullable PlayerConfig playItem(int index)
Advances playback to the Playlist item specified by the index.- Returns:
- the item to play. If null, the end of the Playlist has been reached.
-
previousItem
@Nullable PlayerConfig previousItem()
Moves backwards in the Playlist.- Returns:
- the next item to play. If null, the start of the Playlist has been reached.
-
-