MediaPlayerAdapter
open class MediaPlayerAdapter : PlayerAdapter
kotlin.Any | ||
↳ | androidx.leanback.media.PlayerAdapter | |
↳ | androidx.leanback.media.MediaPlayerAdapter |
This implementation extends the PlayerAdapter
with a MediaPlayer
.
Summary
Public constructors | |
---|---|
Constructor. |
Public methods | |
---|---|
open Long | |
open Long | |
open Long | |
MediaPlayer! |
Return the MediaPlayer associated with the MediaPlayerAdapter. |
open Int |
Return updating interval of progress UI in milliseconds. |
open Boolean | |
open Boolean | |
open Unit |
onAttachedToHost(host: PlaybackGlueHost!) |
open Unit | |
open Unit |
pause() |
open Unit |
play() |
open Unit |
release() Release internal MediaPlayer. |
open Unit |
reset() Will reset the |
open Unit | |
open Boolean |
setDataSource(uri: Uri!) Sets the media source of the player witha given URI. |
open Unit |
setProgressUpdatingEnabled(enabled: Boolean) |
Protected methods | |
---|---|
open Boolean |
Called to indicate an error. |
open Boolean |
Called to indicate an info or a warning. |
open Unit |
Called to indicate the completion of a seek operation. |
Inherited functions | |
---|---|
Public constructors
Public methods
getBufferedPosition
open fun getBufferedPosition(): Long
getCurrentPosition
open fun getCurrentPosition(): Long
getDuration
open fun getDuration(): Long
getMediaPlayer
fun getMediaPlayer(): MediaPlayer!
Return the MediaPlayer associated with the MediaPlayerAdapter. App can use the instance to config DRM or control volumes, etc. Warning: App should not use the following seven listeners as they are controlled by MediaPlayerAdapter. If that's the case, app should write its own PlayerAdapter class. MediaPlayer#setOnPreparedListener
MediaPlayer#setOnVideoSizeChangedListener
MediaPlayer#setOnErrorListener
MediaPlayer#setOnSeekCompleteListener
MediaPlayer#setOnCompletionListener
MediaPlayer#setOnInfoListener
MediaPlayer#setOnBufferingUpdateListener
Return | |
---|---|
MediaPlayer! |
The MediaPlayer associated with the MediaPlayerAdapter. |
getProgressUpdatingInterval
open fun getProgressUpdatingInterval(): Int
Return updating interval of progress UI in milliseconds. Subclass may override.
Return | |
---|---|
Int |
Update interval of progress UI in milliseconds. |
isPlaying
open fun isPlaying(): Boolean
isPrepared
open fun isPrepared(): Boolean
Return | |
---|---|
Boolean |
True if MediaPlayer OnPreparedListener is invoked and got a SurfaceHolder if PlaybackGlueHost provides SurfaceHolder. |
onAttachedToHost
open fun onAttachedToHost(host: PlaybackGlueHost!): Unit
onDetachedFromHost
open fun onDetachedFromHost(): Unit
pause
open fun pause(): Unit
play
open fun play(): Unit
release
open fun release(): Unit
Release internal MediaPlayer. Should not use the object after call release().
reset
open fun reset(): Unit
Will reset the MediaPlayer
and the glue such that a new file can be played. You are not required to call this method before playing the first file. However you have to call it before playing a second one.
setDataSource
open fun setDataSource(uri: Uri!): Boolean
Sets the media source of the player witha given URI.
Return | |
---|---|
Boolean |
Returns true if uri represents a new media; false otherwise. |
See Also
Protected methods
onError
protected open fun onError(
what: Int,
extra: Int
): Boolean
Called to indicate an error.
Parameters | |
---|---|
what |
Int: the type of error that has occurred: |
extra |
Int: an extra code, specific to the error. Typically implementation dependent.
|
Return | |
---|---|
Boolean |
True if the method handled the error, false if it didn't. Returning false, will cause the
|