toro icon indicating copy to clipboard operation
toro copied to clipboard

How to make playerview full screen button with seeker button for volume

Open hafiz013 opened this issue 4 years ago • 2 comments

May i know this library can support for full screen button and seekbar button for volume control.tq

hafiz013 avatar Apr 28 '20 05:04 hafiz013

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.

shivamsoods avatar May 01 '20 09:05 shivamsoods

@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.

eneim avatar Jun 30 '20 14:06 eneim