这是this question的扩展
根据我的研究,对于iPhone/iPad上的视频元素,同时按下“完成”和“暂停”会触发“暂停”事件。因此,如果我希望在按下“完成”按钮后启动一些所需的网页行为,则需要监听“暂停”事件。
player = document.getElementById('videoplayer');
player.addEventListener("pause", function() {
//desired "done button" behavior defined here
}, false);
根据Arv-ToolTwist's answer的原始问题,区分“完成”和“暂停”的方式是检查
webkitDisplayingFullscreen
bool 值(由于“完成”按钮退出全屏显示,因此 bool 值将返回false)。player.addEventListener("pause", function() {
if(!player.webkitDisplayingFullscreen) {
//desired "done button" behavior defined here
}
}, false);
但是,如果用户在播放器处于全屏模式时暂停视频,然后在视频暂停时按下“完成”,则不会启动“所需的完成按钮行为”。
我的研究几乎没有这方面的信息,但是我的假设是,“pause”事件没有第二次触发,或者在
webkitDisplayingFullscreen
bool 值更改为“false”之前又触发了第二次。无论哪种方式,设备都可以分辨“完成”和“暂停”之间的区别(即使播放器已经暂停了),所以我想知道最佳答案
这是您要寻找的事件:
player.addEventListener('webkitendfullscreen', onVideoEndsFullScreen, false);
当用户按下“完成”按钮时,确实会触发此事件。 (iPhone/iTouch)
在这个问题中得到回答,How to figure out when a HTML5 video player enters the full screen mode on iOS / iPads?
这只留下了主页按钮事件...似乎没有可靠的事件(请参阅底部2个帖子)https://discussions.apple.com/thread/4182660?start=0&tstart=0
关于iphone - 在iPhone上使用HTML5视频元素后,如何检测 "pause"和 "done"之间的区别?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11112150/