【问题标题】:Video onended() or ended does not fire in Safari on iOS视频 onended() 或 end 在 iOS 上的 Safari 中不触发
【发布时间】:2020-07-30 17:04:23
【问题描述】:

以下代码在 Chrome 或桌面版 Firefox 中完美运行,但在 iOS 上的 Safari 中无法运行。

<video class="video-js vjs-fluid vjs-default-skin" preload playsinline webkit-playsinline  data-setup='{ "inactivityTimeout": 0 }' disablePictureInPicture controls muted controlsList="nodownload nofullscreen noremoteplayback" id="fVideo">
     <source src="myvideo.mp4" type="video/mp4">
</video>

...这里是javascript

<script>
    document.getElementById('fVideo').addEventListener('ended',myHandler,false);
    function myHandler(e) {
        alert('video ended');
    }
</script>

任何帮助将不胜感激。

【问题讨论】:

    标签: javascript jquery ios safari html5-video


    【解决方案1】:

    用videojs函数回调替换了Javascript代码,现在可以使用了。

    <script>
        var player = videojs('fVideo');
        var options = {};
        var player = videojs('fVideo', options, function onPlayerReady() {
            this.on('ended', function() {
                alert('video ended');
            });
        });
    </script>
    

    【讨论】:

      猜你喜欢
      • 2020-07-20
      • 2015-11-27
      • 2020-02-24
      • 1970-01-01
      • 2018-10-07
      • 2011-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多