有没有办法在 iPhone 上捕获 HTML5 视频事件?

发布于 2024-09-04 03:24:09 字数 434 浏览 2 评论 0原文

我有我的标准视频标签,可以在 Chrome 中正常播放;

<video width="x" height="y" src="video.mp4"></video>

视频本身在 iPhone 上播放得很好,但是没有办法监听事件吗?有什么活动吗?我想使用“结束”事件,但即使是“点击”或“播放”也会有帮助!

该标准

video.addEventListener('ended', function() {
  alert('this adds nothing');
}, false);

根本不起作用,我也无法跟踪视频标签上的点击事件(以相同的方式)。

如果没有,是否可以在视频顶部添加透明,正常跟踪单击事件,然后触发视频的播放事件,以便视频正常加载到单独的窗口中?

I have my standard video tag which is playing fine in Chrome;

<video width="x" height="y" src="video.mp4"></video>

The video itself plays fine on the iPhone, however, is there no way to listen for events? Any kind of event? I'd like to use the 'ended' event, but even a 'click' or 'play' would be helpful!

The standard

video.addEventListener('ended', function() {
  alert('this adds nothing');
}, false);

doesn't work at all, and nor can I track a click event (In the same way) on the video tag.

If not, would it be possible to perhaps add a transparent over the top of the video, track a click event to that as normal but then fire the play event for the video so that the video loads in the separate window as normal?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

灼痛 2024-09-11 03:24:09

这非常适合我在 iphone/ipad/safari/chrome 上使用

 $('#video_1').bind("结束",videoFinished);

函数视频完成(e) {
console.log("我完成了); }

This works perfectly for me on an iphone/ipad/safari/chrome

       $('#video_1').bind("ended",videoFinished);

function videoFinished(e) {
console.log("im done); }

待天淡蓝洁白时 2024-09-11 03:24:09

以下是 Safari HTML5 音频和视频的示例指南

<!DOCTYPE html>
<html>
  <head>
   <title>Sequential Movies</title>
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <script type="text/javascript">
       // listener function changes src
       function myNewSrc() {
          var myVideo = document.getElementsByTagName('video')[0];
          myVideo.src="http://homepage.mac.com/qt4web/sunrisemeditations/myMovie.m4v";
          myVideo.load();
          myVideo.play();
        }

       // function adds listener function to ended event -->

        function myAddListener(){
         var myVideo = document.getElementsByTagName('video')[0];
         myVideo.addEventListener('ended',myNewSrc,false);
        }
   </script>

  </head>

  <body onload="myAddListener()">
      <video controls
        src="http://homepage.mac.com/qt4web/sunrisemeditations/A-chord.m4v"
       >
      </video>
  </body>
</html>

Here is an example from Safari HTML5 Audio and Video Guide

<!DOCTYPE html>
<html>
  <head>
   <title>Sequential Movies</title>
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <script type="text/javascript">
       // listener function changes src
       function myNewSrc() {
          var myVideo = document.getElementsByTagName('video')[0];
          myVideo.src="http://homepage.mac.com/qt4web/sunrisemeditations/myMovie.m4v";
          myVideo.load();
          myVideo.play();
        }

       // function adds listener function to ended event -->

        function myAddListener(){
         var myVideo = document.getElementsByTagName('video')[0];
         myVideo.addEventListener('ended',myNewSrc,false);
        }
   </script>

  </head>

  <body onload="myAddListener()">
      <video controls
        src="http://homepage.mac.com/qt4web/sunrisemeditations/A-chord.m4v"
       >
      </video>
  </body>
</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文