Hello,
I have a problem in one of my native app where I have a video (using https://github.com/videojs/video.js) in my Webview (where the android type of webview is android.webkit.WebView
).
The problem is that I can display the video (it’s an <iframe>
with the property allowfullscreen in my webview) but when I click on the full screen button, nothing happens.
I already looked up for my problem on several forums (see bottom of this message for the consulted resources) and apparently for the android webview there is the need to add two functions:
(from the docs https://developer.android.com/reference/android/webkit/WebView.html)
In order to support full screen — for video or other HTML content — you need to set a WebChromeClient and implement both onShowCustomView(View, WebChromeClient.CustomViewCallback) and onHideCustomView(). If the implementation of either of these two methods is missing then the web contents will not be allowed to enter full screen. Optionally you can implement getVideoLoadingProgressView() to customize the View displayed whilst a video is loading.
My current implementation is:
application.android.on(application.AndroidApplication.activityResumedEvent, () => {
console.log(`WebViewAppComponent: App resumes`);
let myWebChromeClient = android.webkit.WebChromeClient.extend({
onShowCustomView: function(view, callback) {},
onHideCustomView: function() {}
});
this.webView.android.setWebChromeClient(myWebChromeClient);
});
(I have placed the code in on of the application.AndroidApplication
event cause otherwise android
was not defined)
But it’s not solving my problem. Does anyone have a typescript solution for this problem?
Thanks in advance.
Consulted resources:
- WebView Youtube iframe allowfullscreen doesn't work
- https://stackoverflow.com/questions/29503955/html5-video-on-webview-missing-fullscreen-button-on-lollipop/36188659#36188659
- https://stackoverflow.com/questions/15796661/android-webview-app-wont-let-video-player-go-full-screen/16199649#16199649
- https://stackoverflow.com/questions/12794041/how-to-response-to-full-screen-button-in-websites-that-has-videos/13005145#13005145
- not working full screen android videoplayer