//var mobVideoId = ''; //var videoID = $('#player').attr('data-videoId'); //var mobVideoId = $('#player').attr('data-mobVideoId'); var videoID = atob($("#player").attr("data-videoid")); var mobVideoId = atob($("#player").attr("data-mobvideoid")); var displayScreen = ''; var w1 = $(window).width(); var h1 = $(window).height(); if (w1 > 768) { // land displayScreen = 'desktop'; $(".responsive-video").css({ }); } else { //portrait //414 736 displayScreen = 'mobile'; if(mobVideoId != ''){ videoID = mobVideoId; } $(".responsive-video").attr('id','mob-video'); $(".video-overlay-alt").addClass("mob-thmbnl"); $(".video-overlay-play").addClass("mob-thmbnl"); $(".embed-responsive.responsive-video").addClass("mob-responsive"); } var tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); var player; var playing = true; function onYouTubeIframeAPIReady() { player = new YT.Player('player', { height: '600', width: '900', videoId: videoID, playerVars: { autoplay: 1, mute: 1, cc_load_policy: 0, controls: 0, disablekb: 1, fs: 0, playsinline: 1, modestbranding: 1, iv_load_policy: 3, rel: 0, showinfo: 0, host: 'https://www.youtube.com' }, events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } }); } function onPlayerReady(event) { player.playVideo(); $("#mute-button").show(); $("#pause-button").hide(); $("#first-button").hide(); $(".videoRow").css("padding-top", "55px"); } function onPlayerStateChange(event) { if (event.data == YT.PlayerState.PAUSED) { playing = false; } if (event.data == YT.PlayerState.PLAYING) { playing = true; } // Add this code to handle video ending if (event.data == YT.PlayerState.ENDED) { // Get video duration var duration = player.getDuration(); // Seek to 2 seconds before the end player.seekTo(duration - 2, true); // Pause the video player.pauseVideo(); // Show the pause overlay if needed myPauseVideo(); } } function myPauseVideo(){ player.pauseVideo(); $('.desktop__heading').show(); $('.mobile__heading').removeClass('removeheading'); $(".videoRow").removeClass("playing"); if(displayScreen == 'desktop'){ $(".container-video").css("max-width", "70%"); } else { $(".container-video").css("max-width", "90%"); } $(".videoContainerNew").css("max-width", "60%"); $('.green-gradient .container').removeClass("container-fluid"); $('.header-sec .heading_main').removeClass("hide"); $('.videoContainerNew').css("margin-top", "20px"); $('.header-sec').css("padding-top", "1rem"); if(displayScreen == 'desktop'){ $('.responsive-video').css({ // paddingBottom: "46.25%" }); } $('.green-gradient .container-fluid').addClass("container"); $('.green-gradient .container-fluid').removeClass("p-0 m-0"); $('.green-gradient .container-fluid .row').removeClass("m-0"); $('.green-gradient .container-fluid .row .text-center').removeClass("p-0"); // $('.green-gradient .container-fluid .row').addClass("pb-md-5 py-3 pt-md-3"); $('.parentContainer').addClass('pause-section'); // $('.mobile-responsive').css("height","93vh"); //$('.video-overlay-play').css({"display": "block"}); } function myPlayVideo(){ $('.desktop__heading').hide(); $('.mobile__heading').addClass('removeheading'); player.playVideo(); $(".videoRow").addClass("playing"); $(".playing").css("padding-top", "0px"); $("#mute-button").hide(); $('.mobile-responsive').css("height","100vh"); if(displayScreen == 'desktop'){ $(".container-video").css("max-width", "70%"); } else { $(".container-video").css("max-width", "90%"); } $(".videoContainerNew").css("max-width", "100%"); $(".videoSection").css("padding: 0px 0px;"); $("#container-custom").css("padding", "0"); $("#container-custom").css("max-width", "100%"); $('.green-gradient .container').addClass("container-fluid"); $('.header-sec .heading_main').addClass("hide"); $('.videoContainerNew').css("margin-top", "0"); $('.header-sec').css("padding-top", "0"); $('.green-gradient .container-fluid .row').removeClass("pb-md-5 py-3 pt-md-3"); $('.green-gradient .container-fluid').addClass("p-0 m-0"); $('.green-gradient .container-fluid .row').addClass("m-0"); $('.green-gradient .container-fluid .row .text-center').addClass("p-0"); $('.parentContainer').removeClass('pause-section'); //Fix mobile window overflowing vertically and not showing subtitle text if (w1 > 768) { } else { } } $("#mute-button").click(function() { $('.screen-overlay').addClass('active'); $("#mute-button").hide(); player.seekTo(0); player.playVideo(); $('.desktop__heading').hide(); $('.mobile__heading').addClass('removeheading'); $('.parentContainer').removeClass('pause-section'); if(displayScreen == 'desktop'){ $(".container-video").css("max-width", "70%"); } else { $(".container-video").css("max-width", "90%"); } $(".videoContainerNew").css("max-width", "100%"); $('.header-sec .heading_main').addClass("hide"); $('.videoContainerNew').css("margin-top", "0"); $('.header-sec').css("padding-top", "0"); if (player && player.unMute) { player.unMute(); $("#mute-button").hide(); // $(".videoRow").css("padding-top", "55px"); $('.green-gradient .container').addClass("container-fluid"); } }); $("#pause-button, #first-button").click(function() { $('.screen-overlay').addClass('active'); $('.desktop__heading').hide(); $('.mobile__heading').addClass('removeheading'); myPlayVideo(); player.unMute(); // player.playVideo(); $(".videoRow").css("padding-top", "0px"); $("#pause-button").css('display', 'none'); $("#first-button").css('display', 'none'); //$(".container-video").css("max-width", "60%"); $(".videoContainerNew").css("max-width", "100%"); // if (player && player.unMute && player.playVideo) { // } }); $(".glass-overlay").click(function() { $("#mute-button").hide(); $('.desktop__heading').show(); $('.mobile__heading').removeClass('removeheading'); $('.screen-overlay').removeClass('active'); if (player && player.pauseVideo) { myPauseVideo(); $('.green-gradient .container').removeClass("container-fluid"); $("#pause-button").css('display', 'block'); if(displayScreen == 'desktop'){ // add some code }else if(displayScreen == 'mobile'){ $(".video-overlay-alt").removeClass("mob-thmbnl"); $(".video-overlay-alt").addClass("mob-thmbnl2"); $(".video-overlay-play").removeClass("mob-thmbnl"); $(".video-overlay-play").addClass("mob-thmbnl2"); } } }); function videosize(videoID,mobVideoId) { var w1 = $(window).width(); var h1 = $(window).height(); if (w1 > h1) { } else { //portrait //414 736 videoID = mobVideoId; $(".responsive-video").css({ paddingBottom: "149%" }) } } function getCookie(cname) { let name = cname + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(let i = 0; i