I have a group of MP4 videos which will play when the container is hovered. Please see the 3 images at the bottom of this page for a demo:
https://ts133842-container.zoeysite.com/
This works great in Chrome, however in Safari the video will not play and the console is showing the error when hovering.
Unhandled Promise Rejection: [object DOMError]
I've searched for a solution but haven't been able to find a fix. Please see my code below:
<div class="video-container">
<video loop muted preload="auto">
<source src="video.mp4" type="video/mp4">
</video>
</div>
<div class="image-container"><img src="image.png"/></div>
jQuery(".video-container").hover(hoverVideo, hideVideo);
function hoverVideo(e) {
jQuery('video', this).get(0).play();
jQuery(this).find('.image-container').css('display', 'none');
}
function hideVideo(e) {
jQuery('video', this).get(0).currentTime = 0;
jQuery('video', this).get(0).pause();
jQuery(this).find('.image-container').css('display', 'block');
}
Could anybody share any insight as to why Safari is throwing this error? Thank you very much in advance.
Edit: I've now noticed that this doesn't work on an iPad or iPhone, so isn't just a desktop Safari issue. I'm not sure why I can't find more information about this error online however.