最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I autoplay a video without muting? - Stack Overflow

programmeradmin0浏览0评论

I have a video in my code but I can not make it auto play without muting it. The video has sound but it would auto play without it being muted.

<video autoplay muted loop id="myVideo">
  <source src="weddingv.mp4" type="video/mp4">
</video>

I have a video in my code but I can not make it auto play without muting it. The video has sound but it would auto play without it being muted.

<video autoplay muted loop id="myVideo">
  <source src="weddingv.mp4" type="video/mp4">
</video>

Share Improve this question asked Feb 21, 2020 at 16:16 AnonymousAnonymous 111 gold badge1 silver badge2 bronze badges 5
  • What is your code so far for the autoplay feature? (that you want to change the mute on) – Jeremy Commented Feb 21, 2020 at 16:18
  • that's a very annoying feature, personally – DeveloperLV Commented Feb 21, 2020 at 16:20
  • Most (all?) of the major browsers are cracking down on this. Here's Chrome's write-up: developers.google./web/updates/2017/09/… . Probably the easiest thing you can do is make an easy-to-find "un-mute" button for users to click if they want sound. – WGriffing Commented Feb 21, 2020 at 16:27
  • Does this answer your question? HTML5 video autoplay not working in chrome – sanoj lawrence Commented Feb 21, 2020 at 16:34
  • does this solves your problem stackoverflow./a/49822987/3836908 – sanoj lawrence Commented Feb 21, 2020 at 16:35
Add a ment  | 

3 Answers 3

Reset to default 4

Autoplaying w/ sound

On some browsers, autoplaying with sound does work. However on Chrome it hasn't worked without the mute attribute for some time.

This is well documented here.


Can't you trick Chrome?

Unfortunately you can't trick it by giving it the mute attribute and then unmuting in JavaScript. It also won't work if you try to play the video on page load through JavaScript.

I hope this points you in the right direction.

As per New Policy - https://developer.chrome./blog/autoplay/#new-behaviors. There should be User Interactions to AutoPlay any Videos with Sounds.

Here is an example solution for the same:-

HTML5 Video autoplay with sound unmuted

Hope it works for you and in case it is a different in which you struck then let me know.

Browsers get more and more strict about not allowing non-muted videos to autoplay. It's even worse on mobile devices (very much especially iOS). In my experience (which, sadly, is extensive on this issue), trying to trick browsers (especially iOS browsers) into doing your bidding when it es to video by using JavaScript makes matters even worse (videos start playing in their own window, not inline in your web page, as you presumably want). I say that after bing SO and other sources for solutions.

If for some reason you are not targeting mobile devices, there might be hope here. Otherwise, I'd strongly suggest not wasting more time.

发布评论

评论列表(0)

  1. 暂无评论