PlayerRepositoryImpl

class PlayerRepositoryImpl(mediaMapper: MediaMapper = MediaMapper(MediaExtrasMapperNoopImpl), mediaItemMapper: MediaItemMapper = MediaItemMapper(MediaItemExtrasMapperNoopImpl), playbackStateMapper: PlaybackStateMapper = PlaybackStateMapper()) : PlayerRepository, Closeable

Repository for the current Media3 Player for a Player Activity.

The current implementation is available as soon as the ListenableFuture to connect to the MediaSession completes.

Constructors

Link copied to clipboard
constructor(mediaMapper: MediaMapper = MediaMapper(MediaExtrasMapperNoopImpl), mediaItemMapper: MediaItemMapper = MediaItemMapper(MediaItemExtrasMapperNoopImpl), playbackStateMapper: PlaybackStateMapper = PlaybackStateMapper())

Properties

Link copied to clipboard
open override val availableCommands: StateFlow<Set<Command>>
Link copied to clipboard
open override val connected: StateFlow<Boolean>
Link copied to clipboard
open override val currentMedia: StateFlow<Media?>
Link copied to clipboard
open override val latestPlaybackState: StateFlow<PlaybackStateEvent>
Link copied to clipboard
val player: StateFlow<Player?>
Link copied to clipboard
open override val seekBackIncrement: StateFlow<Duration?>
Link copied to clipboard
open override val seekForwardIncrement: StateFlow<Duration?>
Link copied to clipboard
open override val shuffleModeEnabled: StateFlow<Boolean>

Functions

Link copied to clipboard
open override fun addMedia(media: Media)
open override fun addMedia(index: Int, media: Media)
Link copied to clipboard
open override fun clearMediaList()
Link copied to clipboard
open override fun close()

Close this repository and release the listener from the player.

Link copied to clipboard
fun connect(player: Player, onClose: () -> Unit)

Connect this repository to the player including listening to events.

Link copied to clipboard
open override fun getCurrentMediaIndex(): Int
Link copied to clipboard
open override fun getMediaAt(index: Int): Media?
Link copied to clipboard
open override fun getMediaCount(): Int
Link copied to clipboard
open override fun hasNextMedia(): Boolean
Link copied to clipboard
open override fun hasPreviousMedia(): Boolean
Link copied to clipboard
open override fun pause()
Link copied to clipboard
open override fun play()
Link copied to clipboard
open override fun removeMedia(index: Int)
Link copied to clipboard
open override fun seekBack()
Link copied to clipboard
open override fun seekForward()
Link copied to clipboard
open override fun seekToDefaultPosition(mediaIndex: Int)
Link copied to clipboard
open override fun setMedia(media: Media)

This operation will stop the current MediaItem that is playing, if there is one, as per Player.setMediaItem.

Link copied to clipboard
open override fun setMediaList(mediaList: List<Media>)

This operation will stop the current MediaItem that is playing, if there is one, as per Player.setMediaItems.

open override fun setMediaList(mediaList: List<Media>, index: Int, position: Duration?)

This operation will stop the current MediaItem that is playing, if there is one, as per Player.setMediaItems and set the starting position to the position passed as parameter.

Link copied to clipboard
open override fun setPlaybackSpeed(speed: Float)
Link copied to clipboard
open override fun setShuffleModeEnabled(shuffleModeEnabled: Boolean)
Link copied to clipboard
open override fun skipToNextMedia()
Link copied to clipboard
open override fun skipToPreviousMedia()