KevinnZou / compose-webview-multiplatform

WebView for JetBrains Compose Multiplatform
https://kevinnzou.github.io/compose-webview-multiplatform/
Apache License 2.0
479 stars 58 forks source link

Youtube Player fullScreen button does not work when its played in WebView #168

Closed Vaibhav2002 closed 2 months ago

Vaibhav2002 commented 4 months ago

If I load a Youtube iFrame in this WebView, the fullscreen button does not make the video fullScreen This only happens in Android. On iOS FullScreen button makes the Video fullscreen and also supports screen rotation

Source Code:

val webViewState = rememberWebViewStateWithHTMLData(embed.html)
val navigator = rememberWebViewNavigator()
val bgColor = MaterialTheme.colorScheme.surface
DisposableEffect(Unit) {
    webViewState.webSettings.apply {
        isJavaScriptEnabled = true
        supportZoom = false
        backgroundColor = bgColor
        iOSWebSettings.apply {
            showVerticalScrollIndicator = false
            showHorizontalScrollIndicator = false
            scrollEnabled = false
        }
        androidWebSettings.apply {
            safeBrowsingEnabled = true
        }
    }
    onDispose { }
}
WebView(
    state = webViewState,
    modifier = modifier.height(400.dp),
    navigator = navigator,
    captureBackPresses = false
)
Vaibhav2002 commented 4 months ago

Maybe these methods of the WebChromeClient needs to be overriden

override fun onShowCustomView(view: View, callback: CustomViewCallback) {
  super.onShowCustomView(view, callback)
}

override fun onHideCustomView() {
  super.onHideCustomView()
}
KevinnZou commented 4 months ago

@Vaibhav2002 Thanks for your feedback! Yes, this requires us to override the onShowCustomView and handle the full-screen logic inside. This further requires us to support the customWebChromeClient. However, I am sorry that we are not planning to provide this feature currently since it can be complex to implement it in the multiplatform context.

You are welcome to submit a PR for it or directly fork this lib and define your own logic in it.