-
- All Implemented Interfaces:
-
com.google.android.horologist.media.repository.PlayerRepository,java.io.Closeable,java.lang.AutoCloseable
public final class PlayerRepositoryImpl implements 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.
-
-
Field Summary
Fields Modifier and Type Field Description private final StateFlow<Player>playerprivate final StateFlow<Boolean>connectedprivate final StateFlow<Set<Command>>availableCommandsprivate final StateFlow<Media>currentMediaprivate final StateFlow<PlaybackStateEvent>latestPlaybackStateprivate final StateFlow<Boolean>shuffleModeEnabledprivate final StateFlow<Duration>seekBackIncrementprivate final StateFlow<Duration>seekForwardIncrement
-
Constructor Summary
Constructors Constructor Description PlayerRepositoryImpl(MediaMapper mediaMapper, MediaItemMapper mediaItemMapper, PlaybackStateMapper playbackStateMapper)
-
Method Summary
Modifier and Type Method Description final StateFlow<Player>getPlayer()StateFlow<Boolean>getConnected()StateFlow<Set<Command>>getAvailableCommands()StateFlow<Media>getCurrentMedia()StateFlow<PlaybackStateEvent>getLatestPlaybackState()StateFlow<Boolean>getShuffleModeEnabled()StateFlow<Duration>getSeekBackIncrement()StateFlow<Duration>getSeekForwardIncrement()final Unitconnect(Player player, Function0<Unit> onClose)Connect this repository to the player including listening to events. Unitclose()Close this repository and release the listener from the player. UnitseekToDefaultPosition(Integer mediaIndex)Unitplay()Unitpause()BooleanhasPreviousMedia()UnitskipToPreviousMedia()BooleanhasNextMedia()UnitskipToNextMedia()UnitseekBack()UnitseekForward()UnitsetShuffleModeEnabled(Boolean shuffleModeEnabled)UnitsetMedia(Media media)This operation will stop the current MediaItem that is playing, if there is one, as per Player.setMediaItem. UnitsetMediaList(List<Media> mediaList)This operation will stop the current MediaItem that is playing, if there is one, as per Player.setMediaItems. UnitsetMediaList(List<Media> mediaList, Integer index, Duration position)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. UnitaddMedia(Media media)UnitaddMedia(Integer index, Media media)UnitremoveMedia(Integer index)UnitclearMediaList()IntegergetMediaCount()MediagetMediaAt(Integer index)IntegergetCurrentMediaIndex()UnitsetPlaybackSpeed(Float speed)-
-
Constructor Detail
-
PlayerRepositoryImpl
PlayerRepositoryImpl(MediaMapper mediaMapper, MediaItemMapper mediaItemMapper, PlaybackStateMapper playbackStateMapper)
-
-
Method Detail
-
getConnected
StateFlow<Boolean> getConnected()
-
getAvailableCommands
StateFlow<Set<Command>> getAvailableCommands()
-
getCurrentMedia
StateFlow<Media> getCurrentMedia()
-
getLatestPlaybackState
StateFlow<PlaybackStateEvent> getLatestPlaybackState()
-
getShuffleModeEnabled
StateFlow<Boolean> getShuffleModeEnabled()
-
getSeekBackIncrement
StateFlow<Duration> getSeekBackIncrement()
-
getSeekForwardIncrement
StateFlow<Duration> getSeekForwardIncrement()
-
connect
final Unit connect(Player player, Function0<Unit> onClose)
Connect this repository to the player including listening to events.
-
seekToDefaultPosition
Unit seekToDefaultPosition(Integer mediaIndex)
-
hasPreviousMedia
Boolean hasPreviousMedia()
-
skipToPreviousMedia
Unit skipToPreviousMedia()
-
hasNextMedia
Boolean hasNextMedia()
-
skipToNextMedia
Unit skipToNextMedia()
-
seekForward
Unit seekForward()
-
setShuffleModeEnabled
Unit setShuffleModeEnabled(Boolean shuffleModeEnabled)
-
setMedia
Unit setMedia(Media media)
This operation will stop the current MediaItem that is playing, if there is one, as per Player.setMediaItem.
-
setMediaList
Unit setMediaList(List<Media> mediaList)
This operation will stop the current MediaItem that is playing, if there is one, as per Player.setMediaItems.
-
setMediaList
Unit setMediaList(List<Media> mediaList, Integer index, Duration position)
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.
-
removeMedia
Unit removeMedia(Integer index)
-
clearMediaList
Unit clearMediaList()
-
getMediaCount
Integer getMediaCount()
-
getMediaAt
Media getMediaAt(Integer index)
-
getCurrentMediaIndex
Integer getCurrentMediaIndex()
-
setPlaybackSpeed
Unit setPlaybackSpeed(Float speed)
-
-
-
-