Package 

Interface PlayerRepository

    • 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.

      • seekBack

         abstract Unit seekBack()

        Seek back by the default amount, see Player.seekForward

      • seekForward

         abstract Unit seekForward()

        Seek forward by the default amount, see Player.seekForward

      • pause

         abstract Unit pause()

        Pause the player, see Player.pause

      • 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.