ios - 在 iPhone 原生播放器上避免可搜索和可跳过的 html5 视频广告
<p><p>我设置了一个 HTML5 播放器(使用 video.js),它在视频本身之前播放和广告视频。 </p>
<p>问题出现在 iPhone 设备上,当 Safari 调用原生 iOS 播放器通过搜索控件播放视频时,用户可以轻松跳过广告。</p>
<p> <img src="/image/UJNws.jpg" alt="check this out"/> </p>
<p>我已将属性“playisinline”和“webkit-playisinline”应用到标签中,这仅在 iOS 10 上有效(顺便说一句,您可以在下次更新时本地应用它),但在 iOS 9 上它仍然向本土玩家展示寻求可能性。</p>
<p>我尝试使用 <a href="https://github.com/bfred-it/iphone-inline-video" rel="noreferrer noopener nofollow">this</a>正如其他地方所建议的那样,但它非常有问题并且在我的播放器实现中产生冲突。</p>
<p>我只需要控制全屏 native 播放器并通过将当前播放时间重置为该播放器来避免搜索,但我找不到如何做到这一点。</p>
<p>任何帮助表示赞赏。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您是否尝试过以下代码段?它将阻止向前搜索。 </p>
<p>这个想法很简单,每秒使用一个间隔来抓取当前位置。如果搜索位置大于当前位置,则将其设置回去。这只是一种解决方法:) </p>
<p></p><div class="snippet"data-lang="js"data-hide="false"data-console="true"data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>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);
});
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><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></code></pre>
<p style="font-size: 20px;">关于ios - 在 iPhone 原生播放器上避免可搜索和可跳过的 html5 视频广告,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/40108957/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/40108957/
</a>
</p>
页:
[1]