toro
toro copied to clipboard
How to make playerview full screen button with seeker button for volume
May i know this library can support for full screen button and seekbar button for volume control.tq
No There is no generic solution in the library current to make the videos full screen but you can use a Dialog to create a full screen and add remove the player from main view and add it to the Dialog box.
Initialize the Fullscreen Dialog
private fun initFullScreenDialog() {
fullScreenDialog =
object : Dialog(context, android.R.style.Theme_Black_NoTitleBar_Fullscreen) {
override fun onBackPressed() {
closeFullScreenDialog()
super.onBackPressed()
}
}
}
Open the Full Screen
private fun openFullScreenDialog()
isFullScreen = true
(player_view.parent as ViewGroup).removeView(player_view)
player_view.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT
fullScreenDialog.addContentView(
playerview,
ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
)
fullScreenDialog.show()
}
Closing the full screen
private fun closeFullScreenDialog() {
isFullScreen = false
(player_view.parent as ViewGroup).removeView(player_view)
fullScreenDialog.dismiss()
player_view.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
MainLinearLayout.addView(player_view)
player_view.requestFocus()
}
You can refer to this link for further understanding.
@hafiz013 To create fullscreen player, there is an existing sample in the Facebook demo: https://github.com/eneim/toro/blob/cb59d3a15053741c0ee1ae0a60e32719778aef02/app/src/main/java/im/ene/toro/sample/facebook/timeline/TimelineFragment.java#L145 It is not trivial, but you can follow that. This sample will automatically open full screen player if user rotates the device. You can modify the control flow to make it manual.
About the volume seekbar, it is not the scope of this library, you should consult the ExoPlayer library about customizing the PlayerView UI. To update volume manually, please use the method setVolumeInfo
in the Helper class.