LeanbackPlayerAdapter
@UnstableApi
class LeanbackPlayerAdapter : PlayerAdapter, Runnable
| kotlin.Any | ||
| ↳ | androidx.leanback.media.PlayerAdapter | |
| ↳ | androidx.media3.ui.leanback.LeanbackPlayerAdapter |
Leanback PlayerAdapter implementation for Player.
Summary
Public constructors |
|---|
LeanbackPlayerAdapter(Builds an instance. |
Public functions |
|
|---|---|
Long |
Returns the current buffered position of the media item in milliseconds. |
Long |
Returns the current position of the media item in milliseconds. |
Long |
Returns the duration of the media item in milliseconds. |
Boolean |
Returns true if media is currently playing. |
Boolean |
|
Unit |
onAttachedToHost(host: PlaybackGlueHost!)This method is called attached to associated |
Unit |
This method is called when current associated |
Unit |
pause()Pauses the media player. |
Unit |
play()Starts the media player. |
Unit |
run() |
Unit |
Seek to new position. |
Unit |
setErrorMessageProvider(Sets the optional |
Unit |
setProgressUpdatingEnabled(enable: Boolean)Implement this method to enable or disable progress updating. |
Inherited functions |
||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
LeanbackPlayerAdapter
LeanbackPlayerAdapter(
context: Context!,
player: Player!,
updatePeriodMs: Int
)
Builds an instance. Note that the PlayerAdapter does not manage the lifecycle of the Player instance. The caller remains responsible for releasing the player when it's no longer required.
Public functions
getBufferedPosition
fun getBufferedPosition(): Long
Returns the current buffered position of the media item in milliseconds.
getCurrentPosition
fun getCurrentPosition(): Long
Returns the current position of the media item in milliseconds.
isPrepared
fun isPrepared(): Boolean
| Returns | |
|---|---|
Boolean |
True if media is ready for playback, false otherwise. |
onAttachedToHost
fun onAttachedToHost(host: PlaybackGlueHost!): Unit
This method is called attached to associated PlaybackGlueHost.
| Parameters | |
|---|---|
host: PlaybackGlueHost! |
onDetachedFromHost
fun onDetachedFromHost(): Unit
This method is called when current associated PlaybackGlueHost is attached to a different PlaybackGlue or PlaybackGlueHost is destroyed. Subclass may override. A typical implementation will release resources (e.g. MediaPlayer or connection to playback service) in this method.
seekTo
fun seekTo(positionInMs: Long): Unit
Seek to new position.
| Parameters | |
|---|---|
positionInMs: Long |
New position in milliseconds. |
setErrorMessageProvider
fun setErrorMessageProvider(
errorMessageProvider: ErrorMessageProvider<PlaybackException!>?
): Unit
Sets the optional ErrorMessageProvider.
| Parameters | |
|---|---|
errorMessageProvider: ErrorMessageProvider<PlaybackException!>? |
The |
setProgressUpdatingEnabled
fun setProgressUpdatingEnabled(enable: Boolean): Unit
Implement this method to enable or disable progress updating.
| Parameters | |
|---|---|
enable: Boolean |
True to enable progress updating, false otherwise. |