Customizable full screen in android for player

I am trying to implement fullscreen using bitmovin in android, But fullscreen feature is is not working as expected. Is there any way that we can customize the full screen feature in the bitmovin player. Below is the sample code that I have implemented using bitmovin sample,

       player = binding.playerView.player
    // Instantiate a custom FullscreenHandler
    val customFullscreenHandler = CustomFullscreenHandler(this, binding.playerView)
    // Set the FullscreenHandler to the PlayerView
    binding.playerView.setFullscreenHandler(customFullscreenHandler)

CustomFullScreenHandler class:
class CustomFullscreenHandler(
activity: Activity,
private val playerView: PlayerView
) : FullscreenHandler {
override var isFullscreen = false
private var decorView: View? = activity.window.decorView
private val playerOrientationListener =
PlayerOrientationListener(activity).apply { enable() }

private fun handleFullscreen(fullscreen: Boolean) {
    isFullscreen = fullscreen
    doSystemUiVisibility(fullscreen)
    doLayoutChanges()
}

private fun doSystemUiVisibility(fullScreen: Boolean) {
    decorView?.post {
        val uiParams = getSystemUiVisibilityFlags(fullScreen, true)
        decorView?.systemUiVisibility = uiParams
    }
}

private fun doLayoutChanges() {
    val mainLooper = Looper.getMainLooper()
    val isAlreadyMainLooper = Looper.myLooper() == mainLooper

    if (isAlreadyMainLooper) {
        updateLayout()
    } else {
        val handler = Handler(mainLooper)
        handler.post(::updateLayout)
    }
}

private fun updateLayout() {
    val parentView = playerView.parent
    if (parentView !is ViewGroup) return

    for (i in 0 until parentView.childCount) {
        parentView
            .getChildAt(i)
            .takeIf { it !== playerView }
            ?.visibility = if (this.isFullscreen) View.GONE else View.VISIBLE
    }
}

override fun onFullscreenRequested() = handleFullscreen(true)

override fun onFullscreenExitRequested() = handleFullscreen(false)

override fun onResume() {
    if (isFullscreen) {
        doSystemUiVisibility(isFullscreen)
    }
}

override fun onPause() {}

override fun onDestroy() = playerOrientationListener.disable()

}

private const val ROTATION_THRESHOLD = 5

Player orientation class:
class PlayerOrientationListener(private val activity: Activity) : OrientationEventListener(activity) {
override fun onOrientationChanged(orientation: Int) {
activity.requestedOrientation = when {
abs(orientation - 0) < ROTATION_THRESHOLD → ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
abs(orientation - 90) < ROTATION_THRESHOLD → ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
abs(orientation - 180) < ROTATION_THRESHOLD → ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
abs(orientation - 270) < ROTATION_THRESHOLD → ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
else → return
}
}
}

We wanted to have a customized full scree icon and operate full screen as we require.

Hi, thanks for your question. Can you please help us understand the requirements in detail.

  • Default Bitmovin player UI has a full-screen button, do you want to replace that with a different icon?
  • What UX experience do you want to build w.r.t full screen? Can you please elaborate with use cases and if possible some UI screenshots to help us understand the requirements.
  • What issues are you facing today when trying to customize the behaviour? Can you please elaborate each issue with expected vs actual behaviour information.

Thanks and Regards,
Lucky Goyal