Reputation: 43
I integrated Exo-player with custom UI. Everything is working fine but now i need to add playback speed controls in the UI. Can any one give references for adding it...!
Upvotes: 1
Views: 1056
Reputation: 43
i don't know this answer is correct or not but i used this approach since i'm using my own custom UI. I added one more button on my custom UI and i created a custom popup with playback options whatever i needed based on the response i'm setting the playback speed
simpleExoPlayer.playWhenReady = false
val alertDialog: AlertDialog.Builder = AlertDialog.Builder(requireContext())
alertDialog.setTitle(getString(R.string.playback_speed))
val items = arrayOf("0.5x", "0.75x", "Normal(1x)", "1.25x", "1.5x")
val checkedItem = playbackPosition
alertDialog.setSingleChoiceItems(items, checkedItem, DialogInterface.OnClickListener { dialog, pos ->
when (pos) {
0 -> simpleExoPlayer.setPlaybackParameters(PlaybackParameters(0.5f))
1 -> simpleExoPlayer.setPlaybackParameters(PlaybackParameters(0.75f))
2 -> simpleExoPlayer.setPlaybackParameters(PlaybackParameters(1f))
3 -> simpleExoPlayer.setPlaybackParameters(PlaybackParameters(1.25f))
4 -> simpleExoPlayer.setPlaybackParameters(PlaybackParameters(1.5f))
}
playbackPosition=pos
})
alertDialog.setPositiveButton("Ok",DialogInterface.OnClickListener{ dialog, i ->
simpleExoPlayer.playWhenReady = true
dialog.dismiss()
})
val alert: AlertDialog = alertDialog.create()
alert.setCanceledOnTouchOutside(false)
alert.show()
Upvotes: 3