I need to have a video pop-up that autoplay when the div is shown and fully stops when hidden. It doesn’t matter to me if it’s done with a Video component or an embed, I just need to be able to control it…
This works. I no doubt found this solution on the forum and tweaked. There are some optional fade in / fade out action. This is working with the Webflow video element. This script is in my body custom code for the page concerned.
<script>
$(document).ready(function() {
// set unique id to videoplayer for the Webflow video element
var src = $('.video').children('iframe').attr('src');
// when object with class vid-open is clicked...
$('.vid-open1').click(function(e) {
e.preventDefault();
// change the src value of the video
$('.video').children('iframe').attr('src', src);
$('.vid-wrap').fadeIn();
$('.vid-open1').fadeOut();
});
// when object with class close-vid is clicked...
$('.close-vid').click(function(e) {
e.preventDefault();
$('.video').children('iframe').attr('src', '');
$('.vid-wrap').fadeOut();
$('.vid-open1').fadeIn();
});
});
</script>
Hi @HammerOz, thanks for the suggestion!
Though it’s still not working unfortunately Just to confirm, the unique ID of the video player currently in your script is just “video”? Where in the code exactly does it stops the video? I only see the fade in and out…
@HammerOz, one more question if you don’t mind… Can I add something to the script to also start playing it? Not just make it stops when hidden? The autoplay feature in the Vimeo link doesn’t seem to work… Thanks again!
Thanks for the update!
It’s so odd though, it seems like it starts playing for a second, and then stops - https://copilot-2020.webflow.io/
Any idea what might cause it?