【问题标题】:Video auto play without muted视频自动播放不静音
【发布时间】:2021-02-17 06:36:24
【问题描述】:

如何处理“Uncaught (in promise) DOMException: play() failed because the user didn't first interact with the document”。在桌面上使用 Chrome 66? 我的代码是

<video
    title="Advertisement"
    style="background-color: rgb(0, 0, 0); position: absolute; width: 640px; height: 360px;"
    src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
    autoplay="true"
    muted="muted"></video>

它应该可以在没有静音的情况下工作。

【问题讨论】:

  • 它在没有muted 的情况下工作...
  • This 应该会回答您的问题。

标签: javascript


【解决方案1】:

它在沙盒中运行。 https://codesandbox.io/s/wonderful-blackburn-wrple?file=/src/App.js

在页面加载时播放带声音的视频通常是一种不好的做法,因为用户通常不希望这样做,除非他们在以视频为中心的网站上或希望播放视频。

【讨论】:

    猜你喜欢
    • 2018-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 2016-11-22
    • 1970-01-01
    • 2019-07-09
    • 1970-01-01
    相关资源
    最近更新 更多