是否有“onClose”在iPhone上的全屏视频播放器的事件? [英] Is there an "onClose" event for the fullscreen video player on iPhone?
问题描述
当用户开始播放时,播放器进入全屏模式并播放视频。
当视频结束时,我抓住结束
事件,并通过 myvideo.webkitExitFullScreen();
。关闭视频播放器。
现在,如果用户点击顶部栏中的完成按钮,或播放器通过关闭视频,则播放器实际上关闭时,需要另一个事件video.webkitExitFullScreen ();
。
有没有办法这样做?
更新答案
您可以使用 webkitendfullscreen
和 webkitenterfullscreen
事件:
var vid = document.getElementById(some-vid);
vid.addEventListener('webkitendfullscreen',function(e){
// handle end full screen
});
vid.addEventListener('webkitenterfullscreen',function(e){
// handle enter full screen
});
以前的答案
在这里提到了一个类似的问题:如何在全屏模式下观看HTML5视频时捕获键盘事件? / a> - 不知道如何链接这两个问题。
我只是假设你使用jQuery轻松编写这段代码。您只需要知道视频何时从全屏更改为不全屏模式...所以调整大小可以查看 video.webkitDisplayingFullscreen;
属性。
var isVideoFullscreen = video.webkitDisplayingFullscreen;
$(window).bind(resize,function(e){
//检查浏览器是否退出全屏
if(isVideoFullscreen!= video) webkitDisplayingFullscreen){//视频全屏模式已更改
isVideoFullscreen = video.webkitDisplayingFullscreen;
if(isVideoFullscreen){
//您刚刚输入全屏视频
} else {
//你只有EXITED全屏视频
}
}
});
希望这有助于或指向正确的方向
I am using an html5 video player on a website. When the user starts playing it, the player goes into fullscreen mode and plays the video.
When the video has ended, I catch the ended
event and close the video player via myvideo.webkitExitFullScreen();
.
Now, I need another event when the player actually gets closed either if the user taps the "done" button in top bar or if the player gets closed via video.webkitExitFullScreen();
.
Is there a way to do this?
Updated Answer
You can use the webkitendfullscreen
and webkitenterfullscreen
events:
var vid = document.getElementById("some-vid");
vid.addEventListener('webkitendfullscreen', function (e) {
// handle end full screen
});
vid.addEventListener('webkitenterfullscreen', function (e) {
// handle enter full screen
});
Previous Answer
A similar question was asked here: How do I capture keyboard events while watching an HTML5 video in fullscreen mode? - not sure how to link these 2 questions.
I'm just going to assume you use jQuery for ease of writing this code. You just need to know when the video has changed modes from full-screen to not-full-screen... so on Resize you can check the video.webkitDisplayingFullscreen;
property.
var isVideoFullscreen = video.webkitDisplayingFullscreen;
$(window).bind("resize", function (e) {
// check to see if your browser has exited fullscreen
if (isVideoFullscreen != video.webkitDisplayingFullscreen) { // video fullscreen mode has changed
isVideoFullscreen = video.webkitDisplayingFullscreen;
if (isVideoFullscreen) {
// you have just ENTERED full screen video
} else {
// you have just EXITED full screen video
}
}
});
Hope this helps or points you in the right direction
这篇关于是否有“onClose”在iPhone上的全屏视频播放器的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!