[英]Go Fullscreen with HTML5 Video on iPad/iPhone
I'm trying to play and go fullscreen for an HTML5 video element on an iPad/iPhone via JavaScript, but when I try videoElement.webkitEnterFullScreen(), I see an INVALID_STATE_ERR: Dom Exception 11. 我正在试图通过JavaScript在iPad / iPhone上全屏播放HTML5视频元素,但是当我尝试使用videoElement.webkitEnterFullScreen()时,我看到了一个INVALID_STATE_ERR:Dom Exception 11。
Now, it looks like specific support for this behavior was added here: 现在,看起来在这里添加了对此行为的特定支持:
which specifically prevents going fullscreen without a user gesture. 这特别是在没有用户手势的情况下防止全屏显示。
My question: 我的问题:
Is there a workaround for this? 这有解决方法吗?
I see that Vimeo's HTML5 video player is mimicking this behavior somehow as seen here (on iPad/iPhone) 我看到Vimeo的HTML5视频播放器模仿了这种行为,就像在这里看到的那样(在iPad / iPhone上)
So, it seems it is possible. 所以,似乎有可能。 Am I missing something?
我错过了什么吗?
Testing on iOS simulator Ipad 在iOS模拟器Ipad上测试
Hope I can help someone: 希望我能帮助别人:
<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>
I used this and it worked for me 我用过这个,它对我有用
- (void) makeHTML5VideoFullscreen {
if(webView) {
[webView stringByEvaluatingJavaScriptFromString: @"document.querySelector('video').webkitEnterFullscreen();"];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.