public abstract class MediaControllerGlue extends PlaybackControlGlue
PlaybackOverlayFragment
and a
MediaControllerCompat
.ACTION_CUSTOM_LEFT_FIRST, ACTION_CUSTOM_RIGHT_FIRST, ACTION_FAST_FORWARD, ACTION_PLAY_PAUSE, ACTION_REWIND, ACTION_SKIP_TO_NEXT, ACTION_SKIP_TO_PREVIOUS, PLAYBACK_SPEED_FAST_L0, PLAYBACK_SPEED_FAST_L1, PLAYBACK_SPEED_FAST_L2, PLAYBACK_SPEED_FAST_L3, PLAYBACK_SPEED_FAST_L4, PLAYBACK_SPEED_INVALID, PLAYBACK_SPEED_NORMAL, PLAYBACK_SPEED_PAUSED
Constructor and Description |
---|
MediaControllerGlue(Context context,
PlaybackOverlayFragment fragment,
int[] seekSpeeds)
Constructor for the glue.
|
MediaControllerGlue(Context context,
PlaybackOverlayFragment fragment,
int[] fastForwardSpeeds,
int[] rewindSpeeds)
Constructor for the glue.
|
Modifier and Type | Method and Description |
---|---|
void |
attachToMediaController(MediaControllerCompat mediaController)
Attaches to the given media controller.
|
void |
detach()
Detaches from the media controller.
|
int |
getCurrentPosition()
Returns the current position of the media item in milliseconds.
|
int |
getCurrentSpeedId()
Returns the current playback speed.
|
Drawable |
getMediaArt()
Returns a bitmap of the art for the media item.
|
MediaControllerCompat |
getMediaController()
Returns the media controller currently attached.
|
int |
getMediaDuration()
Returns the duration of the media item in milliseconds.
|
CharSequence |
getMediaSubtitle()
Returns the subtitle of the media item.
|
CharSequence |
getMediaTitle()
Returns the title of the media item.
|
long |
getSupportedActions()
Returns a bitmask of actions supported by the media player.
|
boolean |
hasValidMedia()
Returns true if there is a valid media item.
|
boolean |
isMediaPlaying()
Returns true if media is currently playing.
|
protected void |
pausePlayback()
Pause playback.
|
protected void |
skipToNext()
Skip to the next track.
|
protected void |
skipToPrevious()
Skip to the previous track.
|
protected void |
startPlayback(int speed)
Start playback at the given speed.
|
createControlsRowAndPresenter, createPrimaryActionsAdapter, enableProgressUpdating, getContext, getControlsRow, getFastForwardSpeeds, getFragment, getOnItemViewClickedListener, getRewindSpeeds, getUpdatePeriod, isFadingEnabled, onActionClicked, onKey, onMetadataChanged, onRowChanged, onStateChanged, setControlsRow, setFadingEnabled, setOnItemViewClickedListener, updateProgress
public MediaControllerGlue(Context context, PlaybackOverlayFragment fragment, int[] seekSpeeds)
The PlaybackOverlayFragment
must be passed in.
A OnItemViewClickedListener
and
PlaybackOverlayFragment.InputEventHandler
will be set on the fragment.
context
- fragment
- seekSpeeds
- Array of seek speeds for fast forward and rewind.public MediaControllerGlue(Context context, PlaybackOverlayFragment fragment, int[] fastForwardSpeeds, int[] rewindSpeeds)
The PlaybackOverlayFragment
must be passed in.
A OnItemViewClickedListener
and
PlaybackOverlayFragment.InputEventHandler
will be set on the fragment.
context
- fragment
- fastForwardSpeeds
- Array of seek speeds for fast forward.rewindSpeeds
- Array of seek speeds for rewind.public void attachToMediaController(MediaControllerCompat mediaController)
public void detach()
public final MediaControllerCompat getMediaController()
public boolean hasValidMedia()
PlaybackControlGlue
hasValidMedia
in class PlaybackControlGlue
public boolean isMediaPlaying()
PlaybackControlGlue
isMediaPlaying
in class PlaybackControlGlue
public int getCurrentSpeedId()
PlaybackControlGlue
PlaybackControlGlue.PLAYBACK_SPEED_NORMAL
should be returned.getCurrentSpeedId
in class PlaybackControlGlue
public CharSequence getMediaTitle()
PlaybackControlGlue
getMediaTitle
in class PlaybackControlGlue
public CharSequence getMediaSubtitle()
PlaybackControlGlue
getMediaSubtitle
in class PlaybackControlGlue
public int getMediaDuration()
PlaybackControlGlue
getMediaDuration
in class PlaybackControlGlue
public int getCurrentPosition()
PlaybackControlGlue
getCurrentPosition
in class PlaybackControlGlue
public Drawable getMediaArt()
PlaybackControlGlue
getMediaArt
in class PlaybackControlGlue
public long getSupportedActions()
PlaybackControlGlue
getSupportedActions
in class PlaybackControlGlue
protected void startPlayback(int speed)
PlaybackControlGlue
startPlayback
in class PlaybackControlGlue
speed
- The desired playback speed. For normal playback this will be
PlaybackControlGlue.PLAYBACK_SPEED_NORMAL
; higher positive values for fast forward,
and negative values for rewind.protected void pausePlayback()
PlaybackControlGlue
pausePlayback
in class PlaybackControlGlue
protected void skipToNext()
PlaybackControlGlue
skipToNext
in class PlaybackControlGlue
protected void skipToPrevious()
PlaybackControlGlue
skipToPrevious
in class PlaybackControlGlue