public interface MediaPlayerController
Modifier and Type | Interface and Description |
---|---|
static interface |
MediaPlayerController.Listener
An interface defining callbacks that a media player controller calls on registered listeners.
|
Modifier and Type | Field and Description |
---|---|
static long |
DURATION_UNKNOWN
The duration of the media item is unknown.
|
static int |
INDEX_UNSET
The index of the current media item is unknown.
|
static long |
POSITION_UNKNOWN
The position of the current media item in the queue is unknown.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(MediaPlayerController.Listener listener)
Registers the media player controller to listen to events, which is maintained with a strong reference.
|
void |
addQueueItems(com.apple.android.music.playback.queue.PlaybackQueueItemProvider queueProvider,
int insertionType)
Adds the items from the specified playback queue item provider to the current playback queue insertion type, which controls where the items are loaded in the playback queue.
|
boolean |
canAppendToPlaybackQueue()
A Boolean value that indicates whether it's possible to append items to the playback queue.
|
boolean |
canEditPlaybackQueue()
A Boolean value that indicates whether it's possible to move or remove items from the playback queue.
|
boolean |
canPrependToPlaybackQueue()
A Boolean value that indicates whether it's possible to prepend items to the playback queue.
|
boolean |
canSeek()
A Boolean that indicates whether it's possible to seek to a position in the current playback item.
|
boolean |
canSetRadioLikeState()
Gets whether it is currently possible to set the radio like state for the currently playing item.
|
boolean |
canSetRepeatMode()
A Boolean value that indicates whether it's possible to change the active repeat mode.
|
boolean |
canSetShuffleMode()
A Boolean value that indicates whether it's possible to change the active shuffle mode.
|
boolean |
canSkipToNextItem()
A Boolean value that indicates whether it's possible to skip to the next item in the playback queue.
|
boolean |
canSkipToPreviousItem()
A Boolean value that indicates whether it's possible to skip to the previous item in the playback queue.
|
boolean |
canSkipToQueueItem()
A Boolean value that indicates whether it's possible to the skip to an item in the queue item list.
|
Set<com.apple.android.music.playback.model.MediaPlayerTrackInfo> |
getAvailableTracks()
Gets the set of currently available tracks in the player.
|
long |
getBufferedPosition()
Gets the player's buffered position, in milliseconds.
|
String |
getCurrentContainerHashId() |
int |
getCurrentContainerIndex()
Gets the index of the currently playing item in the current media container.
|
long |
getCurrentContainerPersistentId()
Gets the persistent id of the currently playing media container, or null if there are no items loaded,
or the player is not playing from a container with a persistent id.
|
String |
getCurrentContainerStoreId() |
int |
getCurrentContainerType()
Gets the type of the currently playing media container.
|
PlayerQueueItem |
getCurrentItem()
Gets the current player queue item loaded into the player, which is null if no items have been loaded yet.
|
long |
getCurrentPosition()
Gets the current playback position, in milliseconds.
|
long |
getDuration()
Gets the duration, in milliseconds.
|
int |
getPlaybackQueueIndex()
Gets the index in the playback queue of the currently playing item.
|
int |
getPlaybackQueueItemCount()
Gets the total number of items in the playback queue.
|
float |
getPlaybackRate()
Gets the current playback rate, as a multiple of 1.0 to denote the normal playback rate, 0 if playback is paused or stopped, or a negative value means that playback is playing in reverse.
|
int |
getPlaybackState()
Gets the playback state.
|
List<PlayerQueueItem> |
getQueueItems()
Gets a bounded list of the queued items following the currently playing item in the playback queue, which will update as playback progresses, or new items are added to/removed from the queue.
|
int |
getRepeatMode()
Gets the repeat mode.
|
int |
getShuffleMode()
Gets the shuffle mode.
|
int |
getVideoHeight()
Gets the height, in pixels, of the currently playing video, or 0 if no video is currently playing.
|
float |
getVideoPixelAspectRatio()
Gets the pixel aspect ratio of the currently playing video, or 0 if no video is currently playing.
|
int |
getVideoWidth()
Gets the width, in pixels, of the currently playing video, or 0 if no video is currently playing.
|
boolean |
isBuffering()
A Boolean value that indicates if the player is buffering.
|
boolean |
isLiveStream()
A Boolean value that indicates if the current media is a live stream.
|
void |
moveQueueItemWithId(long sourcePlaybackQueueId,
long targetPlaybackQueueId,
int moveTargetType)
Moves the item with the specified playback queue ID to a position in the playback queue, either before or after the item with the specified target ID.
|
void |
pause()
Pauses playback.
|
void |
play()
Starts or resumes playback.
|
void |
prepare(com.apple.android.music.playback.queue.PlaybackQueueItemProvider queueProvider)
Stops playback, and prepares the queue to add items.
|
void |
prepare(com.apple.android.music.playback.queue.PlaybackQueueItemProvider queueProvider,
boolean playWhenReady)
Stops playback, and prepares the queue to add items and starts playing if specified.
|
void |
prepare(com.apple.android.music.playback.queue.PlaybackQueueItemProvider queueProvider,
int playbackQueueInsertionType,
boolean playWhenReady)
Stops playback, and prepares the queue to add items with the given insertion type and starts playing if specified.
|
void |
release()
Releases this media player controller when it's no longer needed.
|
void |
removeListener(MediaPlayerController.Listener listener)
Unregisters the specified listener from receiving events.
|
void |
removeQueueItemWithId(long playbackQueueId)
Removes the item with the specified playback queue ID from the playback queue, if present.
|
void |
restoreState(boolean block)
Restores any previously saved player state.
|
void |
seekToPosition(long position)
Seeks to the specified position, in milliseconds.
|
void |
setItemPositionProvider(com.apple.android.music.playback.player.PlayerMediaItemPositionProvider itemPositionProvider)
Sets the item position provider, which allows for overriding of the default start position of
each media item in the playback queue.
|
void |
setRadioLikeState(int radioLikeState)
Sets the radio like state for the currently playing item, if that operation is currently supported.
|
void |
setRepeatMode(int repeatMode)
Sets the current repeat mode.
|
void |
setShuffleMode(int shuffleMode)
Sets the current shuffle mode.
|
void |
setTimedTextOutputHandler(com.apple.android.music.playback.player.TimedTextOutput timedTextOutput,
Handler handler)
Sets an output handler for timed text data (subtitles and closed captions).
|
void |
setTimedTextTrackSelection(com.apple.android.music.playback.model.MediaPlayerTrackInfo trackSelection)
Sets the track selection for timed text output.
|
void |
setVideoOutputSurface(Surface videoOutputSurface)
Sets the surface to which video output should be rendered to.
|
void |
skipToNextItem()
Skips to the next item in the playback queue if valid.
|
void |
skipToPreviousItem()
Skips to the previous item in the playback queue if valid.
|
void |
skipToQueueItemWithId(long playbackQueueId)
Skips to the item specified by the given playback queue ID if valid.
|
void |
stop()
Stops playback.
|
static final long DURATION_UNKNOWN
static final int INDEX_UNSET
static final long POSITION_UNKNOWN
void addListener(@NonNull MediaPlayerController.Listener listener)
listener
- The listener to register.void addQueueItems(@NonNull com.apple.android.music.playback.queue.PlaybackQueueItemProvider queueProvider, int insertionType)
queueProvider
- A PlaybackQueueItemProvider which will provide the new playback items.insertionType
- The type of insertion to perform.boolean canAppendToPlaybackQueue()
boolean canEditPlaybackQueue()
boolean canPrependToPlaybackQueue()
boolean canSeek()
boolean canSetRadioLikeState()
boolean canSetRepeatMode()
boolean canSetShuffleMode()
boolean canSkipToNextItem()
boolean canSkipToPreviousItem()
boolean canSkipToQueueItem()
@NonNull Set<com.apple.android.music.playback.model.MediaPlayerTrackInfo> getAvailableTracks()
long getBufferedPosition()
POSITION_UNKNOWN
.@Nullable String getCurrentContainerHashId()
int getCurrentContainerIndex()
INDEX_UNSET
.long getCurrentContainerPersistentId()
@Nullable String getCurrentContainerStoreId()
int getCurrentContainerType()
@Nullable PlayerQueueItem getCurrentItem()
long getCurrentPosition()
POSITION_UNKNOWN
.long getDuration()
DURATION_UNKNOWN
.int getPlaybackQueueIndex()
int getPlaybackQueueItemCount()
float getPlaybackRate()
int getPlaybackState()
@NonNull List<PlayerQueueItem> getQueueItems()
int getRepeatMode()
int getShuffleMode()
int getVideoHeight()
float getVideoPixelAspectRatio()
int getVideoWidth()
boolean isBuffering()
boolean isLiveStream()
void moveQueueItemWithId(long sourcePlaybackQueueId, long targetPlaybackQueueId, int moveTargetType)
sourcePlaybackQueueId
- The source item id to move.targetPlaybackQueueId
- The target item id to move to.moveTargetType
- The type of target move, either before or after the target id.void pause()
void play()
void prepare(@NonNull com.apple.android.music.playback.queue.PlaybackQueueItemProvider queueProvider)
queueProvider
- A PlaybackQueueItemProvider instance responsible for providing items to the new playback queue.void prepare(@NonNull com.apple.android.music.playback.queue.PlaybackQueueItemProvider queueProvider, boolean playWhenReady)
queueProvider
- A PlaybackQueueItemProvider instance responsible for providing items to the new playback queue.playWhenReady
- Whether playback should start once the media has been loaded.void prepare(@NonNull com.apple.android.music.playback.queue.PlaybackQueueItemProvider queueProvider, int playbackQueueInsertionType, boolean playWhenReady)
queueProvider
- A queue provider responsible for providing the new playback queue.playbackQueueInsertionType
- The playback queue insertion type to use for the specified provider.playWhenReady
- Whether playback should start once the media has been loaded.void release()
void removeListener(@NonNull MediaPlayerController.Listener listener)
listener
- The listener to unregister.void removeQueueItemWithId(long playbackQueueId)
playbackQueueId
- The playback queue id of the item to remove.void restoreState(boolean block)
block
- Whether the operation should block the calling thread until it is completevoid seekToPosition(long position)
position
- The position to seek to.void setItemPositionProvider(@Nullable com.apple.android.music.playback.player.PlayerMediaItemPositionProvider itemPositionProvider)
itemPositionProvider
- A PlayerMediaItemPositionProvider instance, or null.void setRadioLikeState(int radioLikeState)
radioLikeState
- The like state to set for the current item.void setRepeatMode(int repeatMode)
repeatMode
- The new repeat mode.void setShuffleMode(int shuffleMode)
shuffleMode
- The new shuffle mode.void setTimedTextOutputHandler(@Nullable com.apple.android.music.playback.player.TimedTextOutput timedTextOutput, @Nullable Handler handler)
timedTextOutput
- An instance of TimedTextOutput, or null to remove timed text output rendering.handler
- A Handler to specify which thread to call the output, or null to use the current thread (if a Handler is associated to it) or the player background thread.void setTimedTextTrackSelection(@Nullable com.apple.android.music.playback.model.MediaPlayerTrackInfo trackSelection)
trackSelection
- The new track selection, or null to deselect the timed text track.void setVideoOutputSurface(@Nullable Surface videoOutputSurface)
videoOutputSurface
- A surface to render video output, or null.void skipToNextItem()
void skipToPreviousItem()
void skipToQueueItemWithId(long playbackQueueId)
playbackQueueId
- The playback queue id of the item to skip to.void stop()