I need some help here.. I have linked video to my images so if someone clicks on my image a video pops up but I want the video should play as soon as someone hovers the image. SCENARIO: there are 4 images in one row(250*250 pixel size) and If someone hovers the first image or any image the video should play in the same size of image(250*250) and if they move mouse to another image this video should stop and video for that particular image should start playing
HTML:
<div class="row">
<div class="col-md-3">
<img src="resources/image.jpg" data-src="https://www.youtube.com/embed/fIHH5-HVS9o?autoplay=1" onclick="showVideo(this)"/>
</div>
<div class="col-md-3">
<img src="resources/image.jpg" data-src="https://www.youtube.com/embed/fIHH5-HVS9o?autoplay=1" onclick="showVideo(this)"/>
</div>
<div class="col-md-3">
< img src="resources/image.jpg" data-src="https://www.youtube.com/embed/fIHH5-HVS9o?autoplay=1" onclick="showVideo(this)"/>
</div>
</div>
JS:
function showVideo(obj){
$("#youtube").attr("src", $(obj).data("src"));
$("#videoModal").on("hide.bs.modal", function () {
$("#youtube").removeAttr("src");
}).modal('show');
}
HTML:
<div class="modal fade" id="videoModal" tabindex="-1" role="dialog" aria-labelledby="videoModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="videoModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<iframe id="youtube" width="100%" height="500px">
</iframe>
</div>
</div>
</div>
</div>