Home > Web Front-end > JS Tutorial > How to Enable Autoplay in Chrome 66 with the `muted` Attribute?

How to Enable Autoplay in Chrome 66 with the `muted` Attribute?

Mary-Kate Olsen
Release: 2024-11-24 17:03:17
Original
582 people have browsed it

How to Enable Autoplay in Chrome 66 with the `muted` Attribute?

Developer's Guide to Handling Autoplay Blocked by Chrome 66 in Desktop Browsers

When attempting to play videos on desktop devices using Chrome version 66, developers may encounter the error: "Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first." This issue stems from Google's recent efforts to enhance user privacy by preventing websites from automatically playing media without user interaction.

However, there's a straightforward solution to bypass this restriction. By simply appending the muted attribute to the video element, you can activate autoplay while ensuring compliance with Chrome's policies.

To demonstrate, consider the following HTML code snippet:

<video
    title="Advertisement"
    webkit-playsinline="true"
    playsinline="true"
   >
Copy after login

By including the muted attribute, the media volume will be muted while preserving autoplay functionality. This solution adheres to Chrome's guidelines while offering an effective workaround for developers.

The above is the detailed content of How to Enable Autoplay in Chrome 66 with the `muted` Attribute?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template