菜鸟教程小白 发表于 2022-12-11 17:52:43

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(&#34;vid1&#34;)) {
videojs(&#34;vid1&#34;).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(&#34;seeking&#34;, function(event) {
      if (currentTime &lt; myPlayer.currentTime()) {
      myPlayer.currentTime(currentTime);
      }
    });

    myPlayer.on(&#34;seeked&#34;, function(event) {
      if (currentTime &lt; 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>&lt;link href=&#34;http://vjs.zencdn.net/4.12/video-js.css&#34; rel=&#34;stylesheet&#34;/&gt;
&lt;script src=&#34;http://vjs.zencdn.net/4.12/video.js&#34;&gt;&lt;/script&gt;
&lt;video id=&#34;vid1&#34; src=&#34;http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4&#34; controls class=&#34;video-js vjs-default-skin vjs-big-play-centered&#34; width=&#34;640&#34; height=&#34;360&#34; preload=&#34;auto&#34;&gt;&lt;/video&gt;</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]
查看完整版本: ios - 在 iPhone 原生播放器上避免可搜索和可跳过的 html5 视频广告