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!