I am having trouble getting chrome to autoplay a video. I have set the video to muted and it auto plays in both Safari and Firefox but not chrome.
Although @richard-lindner's solution didn't work for me, it put me on the right track.
In my case, although the muted
attribute was present, Chrome was ignoring it and failing silently unless it was also explicitly set in javacript e.g.
var video = document.getElementById("myVideo");
video.oncanplaythrough = function() {
video.muted = true;
video.play();
}
Interestingly, forcing the autoplay using javascript but ommitting the video.muted = true
line did display the autoplay policy error in the console, suggesting Chrome is indeed ignoring the muted
attribute in some cases. This to me feels like a bug with Chrome's autoplay policy.
Note that the error occurred only when the video was not cached. If it was cached, autoplay worked as expected.