简体   繁体   English

HTML5视频API-全屏无法在iPad上使用Chrome / Safari浏览器

[英]HTML5 Video API - Fullscreen not working with chrome/safari on iPad

I've created a custom HTML5 Video player using Will Haering's guide: https://wch.io/posts/html5-video-api 我已经使用Will Haering的指南创建了一个自定义HTML5视频播放器: https ://wch.io/posts/html5-video-api

The issue I am having when using Chrome or Safari on an iPad is that the video will not enter fullscreen. 在iPad上使用Chrome或Safari时,我遇到的问题是视频无法进入全屏模式。

The fullscreen Javascript code is as follows: 全屏Javascript代码如下:

fullScreenButton.click(function() {
    if(!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {
        if(video.requestFullscreen) {
            video.requestFullscreen();
        } else if(video.msRequestFullscreen) {
            video.msRequestFullscreen();
        } else if(video.mozRequestFullScreen) {
            video.mozRequestFullScreen();
        } else if(video.webkitRequestFullscreen) {
            video.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
        }
    } else {
        if(document.exitFullscreen) {
            document.exitFullscreen();
        } else if(document.msExitFullscreen) {
            document.msExitFullscreen();
        } else if(document.mozCancelFullScreen) {
            document.mozCancelFullScreen();
        } else if(document.webkitExitFullscreen) {
            document.webkitExitFullscreen();
        }
    }
});

If someone could please advise, as I have looked at the similar posts but yet have had no luck in fixing the issue. 如果有人可以提出建议,因为我看过类似的文章,但还没有解决这个问题的运气。

Apple has separated iPadOS from iOS lately (as of early 2019) and they came up with support for fullscreen api on iPad Safari as early as fall last year (2018). 苹果最近(截至2019年初)将iPadOS与iOS分开,他们最早于去年秋天(2018年)提出了对iPad Safari上全屏api的支持。

Your script is mostly correct, but you can find the full cross-browser and iPadOS 12.x Safari and above solution on the following blogpost: 您的脚本基本上是正确的,但是您可以在以下博客文章中找到完整的跨浏览器和iPadOS 12.x Safari及以上版本的解决方案:

Going fullscreen on iPad Safari. 在iPad Safari上全屏显示。

Disclosure: I have written the blog shared on the aforementioned link. 披露:我已经写了在上述链接上共享的博客。 Note that Chrome on iPadOS still doesn't have support for fullscreen api. 请注意,iPadOS上的Chrome仍不支持全屏API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM