Types

Link copied to clipboard
class Builder(context: Context, clazz: Class<out MediaLibraryService>)
Link copied to clipboard

A listener for events and incoming commands from PillarboxMediaLibrarySession.

Properties

Link copied to clipboard
open override val applicationLooper: Looper
Link copied to clipboard
open override val audioAttributes: AudioAttributes
Link copied to clipboard
Link copied to clipboard

Available session commands

Link copied to clipboard
@get:IntRange(from = 0, to = 100)
open override val bufferedPercentage: Int
Link copied to clipboard
open override val bufferedPosition: Long
Link copied to clipboard

The SessionToken of the connected session, or null if it is not connected.

Link copied to clipboard
open override val contentBufferedPosition: Long
Link copied to clipboard
open override val contentDuration: Long
Link copied to clipboard
open override val contentPosition: Long
Link copied to clipboard
open override val currentAdGroupIndex: Int
Link copied to clipboard
open override val currentAdIndexInAdGroup: Int
Link copied to clipboard
open override val currentCues: CueGroup
Link copied to clipboard
open override val currentLiveOffset: Long
Link copied to clipboard
open override val currentManifest: Any?
Link copied to clipboard
open override val currentMediaItem: MediaItem?
Link copied to clipboard
open override val currentMediaItemIndex: Int
Link copied to clipboard
open override val currentPeriodIndex: Int
Link copied to clipboard
open override val currentPosition: Long
Link copied to clipboard
open override val currentTimeline: Timeline
Link copied to clipboard
open override val currentTracks: Tracks
Link copied to clipboard
open override val currentWindowIndex: Int
Link copied to clipboard
val customLayout: ImmutableList<CommandButton>

Custom layout

Link copied to clipboard
open override val deviceInfo: DeviceInfo
Link copied to clipboard
@get:IntRange(from = 0)
open override var deviceVolume: Int
Link copied to clipboard
open override val duration: Long
Link copied to clipboard

Is connected

Link copied to clipboard
Link copied to clipboard
open override val isCurrentMediaItemLive: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val isCurrentWindowLive: Boolean
Link copied to clipboard
Link copied to clipboard
open override var isDeviceMuted: Boolean
Link copied to clipboard
open override val isLoading: Boolean
Link copied to clipboard
open override val isPlaying: Boolean
Link copied to clipboard
open override val isPlayingAd: Boolean
Link copied to clipboard
open override val maxSeekToPreviousPosition: Long
Link copied to clipboard
open override val mediaItemCount: Int
Link copied to clipboard
open override val mediaMetadata: MediaMetadata
Link copied to clipboard
open override val nextMediaItemIndex: Int
Link copied to clipboard
open override val nextWindowIndex: Int
Link copied to clipboard
Link copied to clipboard
open override val playbackState: Int
Link copied to clipboard
open override val playbackSuppressionReason: Int
Link copied to clipboard
open override val playerError: PlaybackException?
Link copied to clipboard
open override var playlistMetadata: MediaMetadata
Link copied to clipboard
open override var playWhenReady: Boolean
Link copied to clipboard
open override val previousMediaItemIndex: Int
Link copied to clipboard
open override val previousWindowIndex: Int
Link copied to clipboard
open override var repeatMode: Int
Link copied to clipboard
open override val seekBackIncrement: Long
Link copied to clipboard
open override val seekForwardIncrement: Long
Link copied to clipboard

Session activity

Link copied to clipboard

Session extras

Link copied to clipboard
open override var shuffleModeEnabled: Boolean
Link copied to clipboard
open override var smoothSeekingEnabled: Boolean

Controls whether smooth seeking behavior is enabled.

Link copied to clipboard
open override val surfaceSize: Size
Link copied to clipboard
open override val totalBufferedDuration: Long
Link copied to clipboard
open override var trackingEnabled: Boolean

Controls whether media item tracking is enabled.

Link copied to clipboard
Link copied to clipboard
open override val videoSize: VideoSize
Link copied to clipboard
@get:FloatRange(from = 0.0, to = 1.0)
open override var volume: Float

Functions

Link copied to clipboard
open override fun addListener(listener: Player.Listener)
Link copied to clipboard
open override fun addMediaItem(mediaItem: MediaItem)
open override fun addMediaItem(index: Int, mediaItem: MediaItem)
Link copied to clipboard
open override fun addMediaItems(mediaItems: List<MediaItem>)
open override fun addMediaItems(index: Int, mediaItems: List<MediaItem>)
Link copied to clipboard
open override fun canAdvertiseSession(): Boolean
Link copied to clipboard
open override fun clearMediaItems()
Link copied to clipboard
open override fun clearVideoSurface()
open override fun clearVideoSurface(surface: Surface?)
Link copied to clipboard
open override fun clearVideoSurfaceHolder(surfaceHolder: SurfaceHolder?)
Link copied to clipboard
open override fun clearVideoSurfaceView(surfaceView: SurfaceView?)
Link copied to clipboard
open override fun clearVideoTextureView(textureView: TextureView?)
Link copied to clipboard
fun Player.currentBufferedPercentageAsFlow(updateInterval: Duration = DefaultUpdateInterval): Flow<Float>

Collects the buffered percentage as a Flow.

Link copied to clipboard
Link copied to clipboard
fun Player.currentMediaMetadataAsFlow(withPlaylistMediaMetadata: Boolean = false): Flow<MediaMetadata>

Collects the media metadata as a Flow.

Link copied to clipboard
fun Player.currentPositionAsFlow(updateInterval: Duration = DefaultUpdateInterval): Flow<Long>

Collects the current position of the player as a Flow.

Link copied to clipboard

Returns the current playback position as a percentage of the total duration.

Link copied to clipboard
open override fun decreaseDeviceVolume()
open override fun decreaseDeviceVolume(flags: Int)
Link copied to clipboard

Disables the audio track.

Link copied to clipboard

Disables the text track.

Link copied to clipboard

Disables the video track.

Link copied to clipboard

Collects the duration as a Flow.

Link copied to clipboard

Enables the audio track.

Link copied to clipboard

Enables the text track.

Link copied to clipboard

Enables the video track.

Link copied to clipboard
open override fun getApplicationLooper(): Looper
Link copied to clipboard
fun Player.getAspectRatioAsFlow(defaultAspectRatio: Float): Flow<Float>

Collects the aspect ratio of the current video as a Flow.

Link copied to clipboard
open override fun getAudioAttributes(): AudioAttributes
Link copied to clipboard
Link copied to clipboard
@IntRange(from = 0, to = 100)
open override fun getBufferedPercentage(): Int
Link copied to clipboard
open override fun getBufferedPosition(): Long
Link copied to clipboard
fun Player.getChapterAtPosition(positionMs: Long = currentPosition): Chapter?

Retrieves the Chapter that encompasses the given position in the media playback.

Link copied to clipboard
suspend fun getChildren(parentId: String, @IntRange(from = 0) page: Int, @IntRange(from = 1) pageSize: Int, params: MediaLibraryService.LibraryParams? = null): LibraryResult<ImmutableList<MediaItem>>

Get children for the parentId

Link copied to clipboard
open override fun getContentBufferedPosition(): Long
Link copied to clipboard
open override fun getContentDuration(): Long
Link copied to clipboard
open override fun getContentPosition(): Long
Link copied to clipboard
fun Player.getCreditAtPosition(positionMs: Long = currentPosition): Credit?

Retrieves the Credit that encompasses the given position in the media playback.

Link copied to clipboard
open override fun getCurrentAdGroupIndex(): Int
Link copied to clipboard
open override fun getCurrentAdIndexInAdGroup(): Int
Link copied to clipboard
Link copied to clipboard

Returns the chapters for the currently playing media item.

Link copied to clipboard
Link copied to clipboard

Returns the credits for the currently playing media item.

Link copied to clipboard
open override fun getCurrentCues(): CueGroup
Link copied to clipboard

Collects the timeline's default position, in milliseconds, as a Flow.

Link copied to clipboard
open override fun getCurrentLiveOffset(): Long
Link copied to clipboard
open override fun getCurrentManifest(): Any?
Link copied to clipboard
open override fun getCurrentMediaItem(): MediaItem?
Link copied to clipboard
open override fun getCurrentMediaItemIndex(): Int
Link copied to clipboard

Retrieves a snapshot of the current media items in the player.

Link copied to clipboard
open override fun getCurrentPeriodIndex(): Int
Link copied to clipboard
open override fun getCurrentPosition(): Long
Link copied to clipboard
open override fun getCurrentTimeline(): Timeline
Link copied to clipboard
open override fun getCurrentTracks(): Tracks
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun getDeviceInfo(): DeviceInfo
Link copied to clipboard
@IntRange(from = 0)
open override fun getDeviceVolume(): Int
Link copied to clipboard
open override fun getDuration(): Long
Link copied to clipboard
suspend fun getItem(mediaId: String): LibraryResult<MediaItem>

Get item

Link copied to clipboard
Link copied to clipboard
open override fun getMaxSeekToPreviousPosition(): Long
Link copied to clipboard
open override fun getMediaItemAt(index: Int): MediaItem
Link copied to clipboard
open override fun getMediaItemCount(): Int
Link copied to clipboard
open override fun getMediaMetadata(): MediaMetadata
Link copied to clipboard
open override fun getNextMediaItemIndex(): Int
Link copied to clipboard
open override fun getNextWindowIndex(): Int
Link copied to clipboard
Link copied to clipboard

Returns the current playback speed of the player.

Link copied to clipboard
Link copied to clipboard
open override fun getPlaybackState(): Int
Link copied to clipboard
open override fun getPlaybackSuppressionReason(): Int
Link copied to clipboard
open override fun getPlayerError(): PlaybackException?
Link copied to clipboard
open override fun getPlaylistMetadata(): MediaMetadata
Link copied to clipboard
open override fun getPlayWhenReady(): Boolean
Link copied to clipboard
open override fun getPreviousMediaItemIndex(): Int
Link copied to clipboard
Link copied to clipboard
open override fun getRepeatMode(): Int
Link copied to clipboard
suspend fun getSearchResult(query: String, @IntRange(from = 0) page: Int, @IntRange(from = 1) pageSize: Int, params: MediaLibraryService.LibraryParams? = null): LibraryResult<ImmutableList<MediaItem>>

Returns the search result from the library service.

Link copied to clipboard
open override fun getSeekBackIncrement(): Long
Link copied to clipboard
open override fun getSeekForwardIncrement(): Long
Link copied to clipboard
open override fun getShuffleModeEnabled(): Boolean
Link copied to clipboard
open override fun getSurfaceSize(): Size
Link copied to clipboard
open override fun getTotalBufferedDuration(): Long
Link copied to clipboard
fun Player.getUnixTimeMs(positionMs: Long = currentPosition, window: Timeline.Window = Window()): Long

Calculates the unix time corresponding to the given position in the current media item in milliseconds.

Link copied to clipboard
open override fun getVideoSize(): VideoSize
Link copied to clipboard
@FloatRange(from = 0.0, to = 1.0)
open override fun getVolume(): Float
Link copied to clipboard
open operator override fun hasNext(): Boolean
Link copied to clipboard
open override fun hasNextMediaItem(): Boolean
Link copied to clipboard
open override fun hasNextWindow(): Boolean
Link copied to clipboard
open override fun hasPreviousMediaItem(): Boolean
Link copied to clipboard
open override fun increaseDeviceVolume()
open override fun increaseDeviceVolume(flags: Int)
Link copied to clipboard
fun Player.isAtLiveEdge(positionMs: Long = currentPosition, window: Timeline.Window = Window()): Boolean

Checks if the current playback position is at the live edge of a live stream.

Link copied to clipboard
open override fun isCommandAvailable(command: Int): Boolean
Link copied to clipboard
open override fun isCurrentMediaItemDynamic(): Boolean
Link copied to clipboard
open override fun isCurrentMediaItemLive(): Boolean
Link copied to clipboard

Collects whether the current media item is a live stream as a Flow.

Link copied to clipboard
open override fun isCurrentMediaItemSeekable(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun isDeviceMuted(): Boolean
Link copied to clipboard
open override fun isLoading(): Boolean
Link copied to clipboard
fun Player.isPlaybackSpeedPossibleAtPosition(position: Long, speed: Float, window: Timeline.Window = Window()): Boolean

Return if the playback speed is possible at position. Always return true for none live content or if Player.getCurrentTimeline is empty.

Link copied to clipboard
open override fun isPlaying(): Boolean
Link copied to clipboard
open override fun isPlayingAd(): Boolean
Link copied to clipboard

Collects whether the player is playing as a Flow.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun moveMediaItem(currentIndex: Int, newIndex: Int)
Link copied to clipboard
open override fun moveMediaItems(fromIndex: Int, toIndex: Int, newIndex: Int)
Link copied to clipboard
open operator override fun next()
Link copied to clipboard
open override fun pause()
Link copied to clipboard
open override fun play()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun prepare()
Link copied to clipboard
open override fun release()
Link copied to clipboard
open override fun removeListener(listener: Player.Listener)
Link copied to clipboard
open override fun removeMediaItem(index: Int)
Link copied to clipboard
open override fun removeMediaItems(fromIndex: Int, toIndex: Int)
Link copied to clipboard
open override fun replaceMediaItem(index: Int, mediaItem: MediaItem)
Link copied to clipboard
open override fun replaceMediaItems(fromIndex: Int, toIndex: Int, mediaItems: List<MediaItem>)
Link copied to clipboard

Run the task in the same thread as Player.getApplicationLooper if it is necessary.

Link copied to clipboard

Requests a search from the library service.

Link copied to clipboard
open override fun seekBack()
Link copied to clipboard
open override fun seekForward()
Link copied to clipboard
open override fun seekTo(positionMs: Long)
open override fun seekTo(mediaItemIndex: Int, positionMs: Long)
Link copied to clipboard
open override fun seekToDefaultPosition()
open override fun seekToDefaultPosition(mediaItemIndex: Int)
Link copied to clipboard
open override fun seekToNext()
Link copied to clipboard
open override fun seekToNextMediaItem()
Link copied to clipboard
open override fun seekToNextWindow()
Link copied to clipboard
open override fun seekToPrevious()
Link copied to clipboard
open override fun seekToPreviousMediaItem()
Link copied to clipboard
open override fun seekToPreviousWindow()
Link copied to clipboard
fun Player.seekToUnixTimeMs(unixTimeMs: Long, window: Timeline.Window = Window())

Seeks the player to the specified unix time in milliseconds within the current media item's window.

Link copied to clipboard

Selects the provided track for playback.

Link copied to clipboard
fun sendCustomCommand(command: SessionCommand, args: Bundle = Bundle.EMPTY): ListenableFuture<SessionResult>
Link copied to clipboard
open override fun setAudioAttributes(audioAttributes: AudioAttributes, handleAudioFocus: Boolean)
Link copied to clipboard

Sets the track selection to automatically select the default audio track.

Link copied to clipboard

Sets the track selection to automatically select the default text track.

Link copied to clipboard

Sets the track selection to automatically select the default video track.

Link copied to clipboard
open override fun setDeviceMuted(muted: Boolean)
open override fun setDeviceMuted(muted: Boolean, flags: Int)
Link copied to clipboard
open override fun setDeviceVolume(volume: Int)
open override fun setDeviceVolume(volume: Int, flags: Int)
Link copied to clipboard
fun Player.setHandleAudioFocus(handleAudioFocus: Boolean)

Sets whether the player should handle audio focus.

Link copied to clipboard
open override fun setMediaItem(mediaItem: MediaItem)
open override fun setMediaItem(mediaItem: MediaItem, resetPosition: Boolean)
open override fun setMediaItem(mediaItem: MediaItem, startPositionMs: Long)
Link copied to clipboard
open override fun setMediaItems(mediaItems: List<MediaItem>)
open override fun setMediaItems(mediaItems: List<MediaItem>, resetPosition: Boolean)
open override fun setMediaItems(mediaItems: List<MediaItem>, startIndex: Int, startPositionMs: Long)
Link copied to clipboard
open override fun setPlaybackParameters(playbackParameters: PlaybackParameters)
Link copied to clipboard
open override fun setPlaybackSpeed(speed: Float)
Link copied to clipboard
open override fun setPlaylistMetadata(mediaMetadata: MediaMetadata)
Link copied to clipboard
open override fun setPlayWhenReady(playWhenReady: Boolean)
Link copied to clipboard
fun setRating(rating: Rating): ListenableFuture<SessionResult>
fun setRating(mediaId: String, rating: Rating): ListenableFuture<SessionResult>
Link copied to clipboard
open override fun setRepeatMode(repeatMode: Int)
Link copied to clipboard
open override fun setShuffleModeEnabled(shuffleModeEnabled: Boolean)
Link copied to clipboard

Sets a track selection override.

Link copied to clipboard
Link copied to clipboard
open override fun setVideoSurface(surface: Surface?)
Link copied to clipboard
open override fun setVideoSurfaceHolder(surfaceHolder: SurfaceHolder?)
Link copied to clipboard
open override fun setVideoSurfaceView(surfaceView: SurfaceView?)
Link copied to clipboard
open override fun setVideoTextureView(textureView: TextureView?)
Link copied to clipboard
open override fun setVolume(volume: Float)
Link copied to clipboard
Link copied to clipboard
open override fun stop()
Link copied to clipboard

Subscribes to a parent id for changes to its children. When there's a change, PillarboxMediaBrowser.Listener.onChildrenChanged will be called with the MediaLibraryService.LibraryParams. You may call PillarboxMediaBrowser.getChildren to get the children.

Link copied to clipboard
fun Player.tickerWhilePlayingAsFlow(interval: Duration = DefaultUpdateInterval): Flow<Unit>

Emits an event every interval while the Player is playing.

Link copied to clipboard
suspend fun unsubscribe(parentId: String): LibraryResult<Void>

Unsubscribes from a parent id for changes to its children, which was previously subscribed by subscribe.

Link copied to clipboard