LeanbackPlayerAdapter
@UnstableApi
public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnable
java.lang.Object | ||
↳ | androidx.leanback.media.PlayerAdapter | |
↳ | androidx.media3.ui.leanback.LeanbackPlayerAdapter |
Leanback PlayerAdapter
implementation for Player
.
Summary
Public constructors |
---|
LeanbackPlayerAdapter( Builds an instance. |
Public methods |
|
---|---|
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 |
|
void |
This method is called attached to associated |
void |
This method is called when current associated |
void |
pause() Pauses the media player. |
void |
play() Starts the media player. |
void |
run() |
void |
seekTo(long positionInMs) Seek to new position. |
void |
setErrorMessageProvider( Sets the optional |
void |
setProgressUpdatingEnabled(boolean enable) Implement this method to enable or disable progress updating. |
Inherited methods |
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
LeanbackPlayerAdapter
public LeanbackPlayerAdapter(
Context context,
Player player,
int updatePeriodMs
)
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 methods
getBufferedPosition
public long getBufferedPosition()
Returns the current buffered position of the media item in milliseconds.
getCurrentPosition
public long getCurrentPosition()
Returns the current position of the media item in milliseconds.
isPrepared
public boolean isPrepared()
Returns | |
---|---|
boolean |
True if media is ready for playback, false otherwise. |
onAttachedToHost
public void onAttachedToHost(PlaybackGlueHost host)
This method is called attached to associated PlaybackGlueHost
.
Parameters | |
---|---|
PlaybackGlueHost host |
onDetachedFromHost
public void onDetachedFromHost()
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
public void seekTo(long positionInMs)
Seek to new position.
Parameters | |
---|---|
long positionInMs |
New position in milliseconds. |
setErrorMessageProvider
public void setErrorMessageProvider(
@Nullable ErrorMessageProvider<PlaybackException> errorMessageProvider
)
Sets the optional ErrorMessageProvider
.
Parameters | |
---|---|
@Nullable ErrorMessageProvider<PlaybackException> errorMessageProvider |
The |
setProgressUpdatingEnabled
public void setProgressUpdatingEnabled(boolean enable)
Implement this method to enable or disable progress updating.
Parameters | |
---|---|
boolean enable |
True to enable progress updating, false otherwise. |