Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Set an HTML5 Video to PAUSE when video player is out of view Re: Set an HTML5 Video to PAUSE when video player is out of view

#97244
dfogge
Participant

thanks to your direction i was finally able to get this working:

if( i < index ) {
// Any element previous to index is given the 'past' class
slide.setAttribute('class', 'past');
document.getElementById('vid').pause();
}
else if( i > index ) {
// Any element subsequent to index is given the 'future' class
slide.setAttribute('class', 'future');
document.getElementById('vid').pause();
}

although, at this point its limited to a single video due to getElementById. next i need to try working out how to apply it to something like getElementsByTagName(‘video’).

any ideas?