So I was wondering if I could make it so that the video on my website starts playing when the user scrolls into the view of it. I've tried quite a few things such as scrollspy and some other code I found on this website, but none of it works, I always get the same result: the website messes up completely, pictures move out of sight, sections change places or disappear and it's not very fun.
This is the current JS code for our MediaElementPlayer:
if ($('.video-promo').length ) {
var player_promo = new MediaElementPlayer('.video-promo', {
videoWidth: '100%',
videoHeight: '100%',
loop: false,
alwaysShowControls: true,
features: [],
});
player_promo.play();
}
And the HTML:
<section class="promo motions">
<video class="video-promo">
<source type="video/mp4" src="assets/video/demo.mp4" />
</video>
<div class="video-overlay"></div>
</section>
Cheers for any help! :D