Play Videos with Audio Despite Chromium Restrictions
2 min
The following Chromium flags are not yet supported on BrightSign players:
- disable-user-media-security
- allow-hidden-media-playback
- autoplay-policy="no-user-gesture-required"
To automatically play videos with audio despite these Chromium autoplay restrictions, start your video with its audio muted and activate the audio shortly after video playback begins. This will work on a player’s browser (not in a Chrome browser).
Example
In the example below:
- source is set to video.mp4
- type is mp4
- width is 640
- height is 360
- The audio is activated 100 milliseconds into the video
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<video id="myVideo" width="640" height="360" autoplay muted>
<source src="video.mp4" type="video/mp4">
</video>
<script>
const videoElement = document.getElementById("myVideo");
videoElement.addEventListener("canplaythrough", function() {
setTimeout(function() {
videoElement.muted = false;
}, 100); // Adjust the delay (in milliseconds) if necessary
});
</script>
</body>
</html>