-
public interface PlayerRepositoryRepository for the current Player.
-
-
Method Summary
Modifier and Type Method Description abstract UnitprepareAndPlay(MediaItem mediaItem, Boolean play)Plays the mediaItem after preparing (buffering). abstract UnitprepareAndPlay(List<MediaItem> mediaItems, Integer startIndex, Boolean play)Plays the mediaItems after preparing (buffering). abstract UnitseekToPreviousMediaItem()Go to the previous track, see Player.seekToPreviousMediaItem. abstract UnitseekToNextMediaItem()Next track, see Player.seekToNextMediaItem abstract LonggetSeekBackIncrement()Returns the seekBack increment. abstract UnitseekBack()Seek back by the default amount, see Player.seekForward abstract LonggetSeekForwardIncrement()Returns the seekForward increment. abstract UnitseekForward()Seek forward by the default amount, see Player.seekForward abstract Unitpause()Pause the player, see Player.pause abstract UnittoggleShuffle()Sets whether shuffling of media items is enabled, see Player.setShuffleModeEnabled abstract UnitupdatePosition()Update the position to show track progress correctly on screen. abstract StateFlow<Player.Commands>getAvailableCommands()The list of available commands at this moment in time. abstract StateFlow<Boolean>getIsPlaying()Is the player already playing or set to start playing as soon as the media has buffered? abstract StateFlow<MediaItem>getCurrentMediaItem()The current media item playing, or that would play when user hit play. abstract StateFlow<TrackPosition>getTrackPosition()The current track position of the player. abstract StateFlow<Boolean>getShuffleModeEnabled()The current value for shuffling of media items mode. -
-
Method Detail
-
prepareAndPlay
abstract Unit prepareAndPlay(MediaItem mediaItem, Boolean play)
Plays the mediaItem after preparing (buffering).
-
prepareAndPlay
abstract Unit prepareAndPlay(List<MediaItem> mediaItems, Integer startIndex, Boolean play)
Plays the mediaItems after preparing (buffering). If mediaItems is null, the existing mediaItems and position will be kept.
-
seekToPreviousMediaItem
abstract Unit seekToPreviousMediaItem()
Go to the previous track, see Player.seekToPreviousMediaItem.
-
seekToNextMediaItem
abstract Unit seekToNextMediaItem()
Next track, see Player.seekToNextMediaItem
-
getSeekBackIncrement
abstract Long getSeekBackIncrement()
Returns the seekBack increment.
-
getSeekForwardIncrement
abstract Long getSeekForwardIncrement()
Returns the seekForward increment.
-
seekForward
abstract Unit seekForward()
Seek forward by the default amount, see Player.seekForward
-
toggleShuffle
abstract Unit toggleShuffle()
Sets whether shuffling of media items is enabled, see Player.setShuffleModeEnabled
-
updatePosition
abstract Unit updatePosition()
Update the position to show track progress correctly on screen. Updating roughly once a second while activity is foregrounded is appropriate.
-
getAvailableCommands
abstract StateFlow<Player.Commands> getAvailableCommands()
The list of available commands at this moment in time. All UI controls that affect the Player should be enabled/disabled based on the available commands.
-
getIsPlaying
abstract StateFlow<Boolean> getIsPlaying()
Is the player already playing or set to start playing as soon as the media has buffered?
-
getCurrentMediaItem
abstract StateFlow<MediaItem> getCurrentMediaItem()
The current media item playing, or that would play when user hit play.
-
getTrackPosition
abstract StateFlow<TrackPosition> getTrackPosition()
The current track position of the player. This is not updated automatically so updatePosition should be called within a ViewModel coroutineScope regularly to update the UI while the activity is in the foreground.
-
getShuffleModeEnabled
abstract StateFlow<Boolean> getShuffleModeEnabled()
The current value for shuffling of media items mode.
-
-
-
-