菜鸟教程小白 发表于 2022-12-11 19:30:49

ios - iOS : Autoplay with sound on click only 上的视频 HTML5


                                            <p><p>我尝试在我的网站上集成一个视频 (MP4),它会在没有声音的情况下自动启动(自动播放),但是当您单击视频放大观看时,您必须能够有声音。</p >

<p>我做不到,是禁止的吗?</p>

<p>PS:我读到了这个:<a href="https://webkit.org/blog/6784/new-video-policies-for-ios/" rel="noreferrer noopener nofollow">https://webkit.org/blog/6784/new-video-policies-for-ios/</a> </p>

<p>使用下面的这段代码,自动播放可以工作,但是当我点击视频时,iPad 上没有声音。 </p>

<pre><code>&lt;video id=&#34;video-autoplay&#34; src=&#34;videos/animaux_720x404.mp4&#34; autoplay muted controls=&#34;controls&#34; playsinline&gt;
   Votre navigateur ne supporte pas les vidéos au format HTML5.&lt;br&gt;
   Veuillez mettre à jour votre navigateur ou utilisez Mozilla Firefox.
&lt;/video&gt;
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>尝试使用它来切换 <code>静音</code> 属性。</p>

<pre><code>$(&#34;video&#34;).click( function (){
    $(this).prop(&#34;muted&#34;, !$(this).prop(&#34;muted&#34;));
});
</code></pre>

<p>另见 <a href="http://blog.millermedeiros.com/unsolved-html5-video-issues-on-ios/" rel="noreferrer noopener nofollow">this post</a>了解 iOS 或官方 <a href="https://developer.apple.com/reference/webkitjs/htmlmediaelement" rel="noreferrer noopener nofollow">Apple doc on HTMLMediaElement</a> 上的功能.</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - iOS : Autoplay with sound on click only 上的视频 HTML5,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/43468113/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/43468113/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - iOS : Autoplay with sound on click only 上的视频 HTML5