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
Mary-Kate OlsenOriginal
2024-11-24 17:03:17647browse

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"
   >

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!

Statement:
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