首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >避免在iPhone原生播放器上搜索和跳过html5视频广告

避免在iPhone原生播放器上搜索和跳过html5视频广告
EN

Stack Overflow用户
提问于 2016-10-18 20:58:08
回答 1查看 1.1K关注 0票数 2

我已经设置了一个HTML5播放器(使用video.js),它在视频本身之前播放和广告视频。

问题出现在iPhone设备上,当Safari调用原生iOS播放器播放视频时,会使用允许用户轻松跳过广告的搜索控件。

我已经将属性"playisinline“和"webkit-playisinline”应用到了标签中,这只在iOS 10上有效(顺便说一下,你可以在下一次更新时本机应用它),但在iOS 9上,它仍然显示原生播放器正在寻找可能性。

我试着按照这里的建议在其他地方使用this,但是它有很多but,并且在我的播放器实现中给出了冲突。

我只需要控制全屏原生播放器,并通过重置当前播放时间来避免搜索,但我找不到如何做到这一点。

感谢您的帮助。

EN

回答 1

Stack Overflow用户

发布于 2016-10-19 10:45:32

你有没有试过下面的代码片段?它将阻止寻求前进。

这个想法非常简单,使用一个间隔来每秒获取当前位置。如果查找位置大于当前位置,则将其设置回去。这只是一种解决方法:)

代码语言:javascript
复制
if (document.getElementById("vid1")) {
  videojs("vid1").ready(function() {
    
    var myPlayer = this;

    //Set initial time to 0
    var currentTime = 0;
    
    //This example allows users to seek backwards but not forwards.
    //To disable all seeking replace the if statements from the next
    //two functions with myPlayer.currentTime(currentTime);

    myPlayer.on("seeking", function(event) {
      if (currentTime < myPlayer.currentTime()) {
        myPlayer.currentTime(currentTime);
      }
    });

    myPlayer.on("seeked", function(event) {
      if (currentTime < myPlayer.currentTime()) {
        myPlayer.currentTime(currentTime);
      }
    });

    setInterval(function() {
      if (!myPlayer.paused()) {
        currentTime = myPlayer.currentTime();
      }
    }, 1000);

  });
}
代码语言:javascript
复制
<link href="http://vjs.zencdn.net/4.12/video-js.css" rel="stylesheet"/>
<script src="http://vjs.zencdn.net/4.12/video.js"></script>
<video id="vid1" src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" controls class="video-js vjs-default-skin vjs-big-play-centered" width="640" height="360" preload="auto"></video>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40108957

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档