I have a Page that has multiple video elements and I want to play one of them when the app loads. But video.play() doesnt seem to do anything.
It works fine if I just have one video but as soon as I add a second one it stops working.
Here is a really simple example that shows my problem:
<!DOCTYPE html> <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="css/style.css"/> <script src="./main.js"></script> </head> <body> <video src="http://example.com/video1.mp4" width="1920"></video> <video src="http://example.com/video2.mp4" width="1920"></video> </body> </html>
window.onload = function init() { var video = document.querySelector('video'); video.muted = true; video.play(); }