Created
May 17, 2021 22:36
-
-
Save cesgarma/0eabe32836caaa913b8a57a445829c43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
.divi-delayed-content { | |
display: none; | |
transition: all 400ms ease !important; | |
} | |
.divi-delayed-content.show-content { | |
display: block; | |
} | |
</style> | |
<script> | |
(function ($) { | |
$(document).ready(function () { | |
//items | |
$diviVideo = $("#divi-video-container video"); | |
videoElement = $("#divi-video-container video")[0]; | |
$delayedContent = $(".divi-delayed-content"); | |
//add timeupdate event on video with a function. | |
$diviVideo.on("timeupdate", function (e) { | |
//add class to show content when specified currentTime is reached. | |
if ( e.target.currentTime >= 15){ | |
console.log("Show content"); | |
$delayedContent.addClass("show-content"); | |
} else { | |
console.log("Do not show content"); | |
$delayedContent.removeClass("show-content"); | |
} | |
}); | |
// Disable controls and video properties | |
if (jQuery('#divi-video-container .et_pb_video_box').length !== 0) { | |
jQuery("#divi-video-container .et_pb_video_box").find('video').attr('playsInline', ''); | |
jQuery('#divi-video-container .et_pb_video_box').find('video').removeAttr('controls'); | |
} | |
// Mute button | |
$mute = $("#divi-mute"); | |
$mute.on("click", function (e) { | |
e.preventDefault(); | |
if( jQuery('#divi-video-container .et_pb_video_box').find('video').prop('muted') ) { | |
jQuery('#divi-video-container .et_pb_video_box').find('video').prop('muted', false); | |
$(e.target).addClass("control-button-mute-off"); | |
$(e.target).removeClass("control-button-mute-on"); | |
} else { | |
jQuery('#divi-video-container .et_pb_video_box').find('video').prop('muted', true); | |
$(e.target).addClass("control-button-mute-on"); | |
$(e.target).removeClass("control-button-mute-off"); | |
} | |
}); | |
// Video ended image | |
$diviVideo.on('ended',function(){ | |
console.log('Video has ended!'); | |
jQuery('#divi-video-container .et_pb_video_overlay').addClass("end-overlay"); | |
}); | |
}); | |
})(jQuery); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment