美文网首页
video:play() failed because the

video:play() failed because the

作者: shmaur | 来源:发表于2018-09-30 17:51 被阅读594次
错误信息

    情况1:刷新几次有时候会自动播放视频,有时候不会;
    情况2:打开开发者工具,正常自动播放视频。

    这是为什么呢??

    网上资料显示是Chrome在66版本后为了避免标签产生随机噪音。Chrome在18年4月做了更改,浏览器为了提高用户体验,减少数据消耗,现在都在遵循autoplay政策。

     1.muted autoplay始终被允许
     2.音乐的autoplay 只有在下面集中情况下起作用:
        2.1.有用户行为发生像(click,tap,etc).
         2.2.对于桌面程序,用户已经提前播放了音频
         2.3.对于移动端用户将音频网址home screen.

     解决方案一:测试通过
    1、Open chrome://flags/#autoplay-policy

打开设置页面
    2、Setting:No user gesture is required
    3、Relaunch Chrome 设置后重启Chrome

     解决方案二:测试通过
    设置 video 为静音状态就可以解决,添加属性muted

<video src="../static/OpeningTrailer.mp4" autoplay muted width="420" preload class="video" id="videoMp4">
        </video>

相关文章

网友评论

      本文标题:video:play() failed because the

      本文链接:https://www.haomeiwen.com/subject/nvnwoftx.html