gpt4 book ai didi

javascript - 在 iPad/iPhone 上使用 HTML5 视频全屏显示

转载 作者:数据小太阳 更新时间:2023-10-29 04:15:12 24 4
gpt4 key购买 nike

我正在尝试通过 JavaScript 在 iPad/iPhone 上播放和全屏显示 HTML5 视频元素,但是当我尝试 videoElement.webkitEnterFullScreen() 时,我看到一个 INVALID_STATE_ERR:Dom 异常 11。

我的 Code

对于 Example

现在,它看起来像是对this behavior 的具体支持在此处添加:

它专门防止在没有用户手势的情况下进入全屏。

我的问题:

有解决办法吗?

我看到 Vimeo 的 HTML5 视频播放器正在以某种方式模仿这种行为 here(在 iPad/iPhone 上)

所以,这似乎是可能的。我错过了什么吗?

最佳答案

在iOS模拟器Ipad上测试

希望我能帮助别人:

<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
var vid;

function init() {
vid = document.getElementById("myVideo");
vid.addEventListener("loadedmetadata", goFullscreen, false);
}

function goFullscreen() {
vid.webkitEnterFullscreen();
}

$(document).ready(function(){
init();

$("#myVideo").bind('ended', function(){
$('#myVideo')[0].webkitExitFullScreen();
});
});
</script>
</head>
<body>
<h1>Fullscreen Video</h1>
<video src="movie.mp4" id="myVideo" autoplay controls >
</video>
</body>
</html>

关于javascript - 在 iPad/iPhone 上使用 HTML5 视频全屏显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5316533/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com