It plays when you hover only after you click somewhere on the screen.

<video id="myVideo" poster="images/slide1.jpg"> <source src="videos/video1.mp4"> <a href="videos/video1.mp4">Скачайте видео</a>. </video> <script> window.onload = function(){ vid = document.getElementById('myVideo'); vid.addEventListener('mouseenter', function() { vid.play(); }); vid.addEventListener('mouseleave', function() { vid.pause(); }); } </script> 

Error in the console: Uncaught (in promise) DOMException:

  • Well, you yourself have just written the answer to your question. What word is not clear to you in the text of the error? - andreymal
  • Is there any solution? - IvanZ
  • No, the behavior is absolutely correct, and that was exactly what the browser developers intended - andreymal

0