How to keep playing full screen video from WebView after rotation on Android

641 Views Asked by At

When the user clicks the full screen button on a video in a WebView, WebChromeClient calls onShowCustomView with the custom video view. I use this callback to add the view to the fragment and display it full screen.

However, when I rotate the device, the activity is destroyed (as expected) along with the custom video view.

How can I make the WebView show the custom video view after rotation (without losing the current state of the video, e.g. playing/paused and offset)? After calling restoreState with the WebView's saved instance state, it does not invoke WebChromeClient's onShowCustomView callback and seems to have no memory that the user was watching a video. Even if I were to somehow save the video, it would no longer be connected to the WebView, and clicking the button to exit full screen would no longer trigger WebChromeClient's onHideCustomView callback.

0

There are 0 best solutions below