Created
January 29, 2023 11:19
-
-
Save ademirqueiroga/db75e1b6bbe9f048bc7258f489faaa12 to your computer and use it in GitHub Desktop.
BasicTransportControlsGlue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BasicTransportControlsGlue( | |
context: Context, | |
playerAdapter: BasicMediaPlayerAdapter, | |
) : PlaybackTransportControlGlue<BasicMediaPlayerAdapter>(context, playerAdapter) { | |
// Primary actions | |
private val forwardAction = PlaybackControlsRow.FastForwardAction(context) | |
private val rewindAction = PlaybackControlsRow.RewindAction(context) | |
private val nextAction = PlaybackControlsRow.SkipNextAction(context) | |
private val previousAction = PlaybackControlsRow.SkipPreviousAction(context) | |
init { | |
isSeekEnabled = true // Enables scrubbing on the seekbar | |
} | |
override fun onCreatePrimaryActions(primaryActionsAdapter: ArrayObjectAdapter) { | |
primaryActionsAdapter.add(previousAction) | |
primaryActionsAdapter.add(rewindAction) | |
super.onCreatePrimaryActions(primaryActionsAdapter) // Adds play/pause action | |
primaryActionsAdapter.add(forwardAction) | |
primaryActionsAdapter.add(nextAction) | |
} | |
override fun onActionClicked(action: Action?) { | |
when (action) { | |
forwardAction -> playerAdapter.fastForward() | |
rewindAction -> playerAdapter.rewind() | |
else -> super.onActionClicked(action) | |
} | |
onUpdateProgress() // Updates seekbar progress | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment