使用iphone上的HTML5视频元素,我如何检测“暂停”视频元素之间的差异。和“完成”? [英] With an HTML5 video element on the iphone, how can I detect the difference between "pause" and "done"?

查看:127
本文介绍了使用iphone上的HTML5视频元素,我如何检测“暂停”视频元素之间的差异。和“完成”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是这个问题

根据我的研究,对于iPhone上的视频元素/按完成和暂停的iPad会触发暂停事件。因此,如果我按下完成按钮后我想要启动某些所需的网页行为,我需要收听暂停事件。

According to my research, for a video element on an iPhone/iPad, pressing both "Done" and "Pause" triggers a "pause" event. So if I have some desired webpage behavior that I want to initiate upon pressing the "done" button, I need to listen for the "pause" event.

player = document.getElementById('videoplayer');
player.addEventListener("pause", function() {
   //desired "done button" behavior defined here
}, false);

根据 Arv-ToolTwist对原始问题的回答,区分完成和暂停的方法是检查 webkitDisplayingFullscreen 布尔值(因为完成按钮退出全屏,布尔值将返回false。

According to Arv-ToolTwist's answer to that original question, the way one differentiates between "done" and "pause" is by checking for the webkitDisplayingFullscreen boolean (since the "done" button exits out of fullscreen, the boolean will return false).

player.addEventListener("pause", function() {
   if(!player.webkitDisplayingFullscreen) {
      //desired "done button" behavior defined here
   }
}, false);

但是,如果用户在播放器处于全屏模式时暂停视频然后按视频暂停时完成,未启动所需的完成按钮行为。

However, in the case where a user pauses the video while the player is in fullscreen mode and then presses "done" while the video is paused, the "desired done button behavior" is not initiated.

我的研究对此几乎没有信息,但我的假设是暂停事件不是第二次被触发,或者它在 webkitDisplayingFullscreen 布尔值变为false之前第二次触发。无论哪种方式,该设备可以分辨完成和暂停之间的差异(即使播放器已经暂停),所以我想知道

My research is turning up little-to-no information on this, but my assumption is that either the "pause" event is not getting triggered a second time, or it gets triggered a second time prior to the webkitDisplayingFullscreen boolean changing to "false". Either way, the device can tell the difference between both "done" and "pause" (even when the player is already paused), so I'm wondering


  1. 设备如何区分,

  2. 是否有办法检测播放器何时退出全屏模式,这样即使播放器已暂停,也请按仍然检测到完成按钮,并且仍然会启动所需的行为。


推荐答案

这是您要查找的事件:

player.addEventListener('webkitendfullscreen', onVideoEndsFullScreen, false);

当用户按下完成按钮时,此事件确实会触发。 (iPhone / iTouch)

This event does indeed fire when the user presses the 'done' button. (iPhone/iTouch)

在这个问题中已经回答,如何确定HTML5视频播放器何时进入iOS / iPad上的全屏模式?

Was answered in this question, 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

This just leaves the home button event...for which there seems to be no reliable event for (see bottom 2 posts) https://discussions.apple.com/thread/4182660?start=0&tstart=0

这篇关于使用iphone上的HTML5视频元素,我如何检测“暂停”视频元素之间的差异。和“完成”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆