From be17e78244db6b8dd0cb245735f4cb42f3f78aea Mon Sep 17 00:00:00 2001 From: rulingcom Date: Fri, 2 Sep 2022 10:57:56 +0800 Subject: [PATCH] Updated --- .../_ad_banner_widget2_video.html.erb | 88 +++++++++++++++++-- 1 file changed, 83 insertions(+), 5 deletions(-) diff --git a/modules/ad_banner/_ad_banner_widget2_video.html.erb b/modules/ad_banner/_ad_banner_widget2_video.html.erb index 6751a95..0c16c9d 100644 --- a/modules/ad_banner/_ad_banner_widget2_video.html.erb +++ b/modules/ad_banner/_ad_banner_widget2_video.html.erb @@ -37,17 +37,46 @@ if (typeof ad_banners_count === 'undefined'){ var ad_banners_count = 0; } + var control_play_btn_pause = function(){ + this.attr('aria-label', '<%= I18n.t("ad_banner.resume") %>'); + this.attr('title', '<%= I18n.t("ad_banner.resume") %>'); + this.find('p').text('<%= I18n.t("ad_banner.resume") %>'); + this.find('i.fa-pause').removeClass('fa-pause').addClass('fa-play'); + } + var control_play_btn_play = function(){ + this.attr('aria-label', '<%= I18n.t("ad_banner.pause") %>'); + this.attr('title', '<%= I18n.t("ad_banner.pause") %>'); + this.find('p').text('<%= I18n.t("ad_banner.pause") %>'); + this.find('i.fa-play').removeClass('fa-play').addClass('fa-pause'); + } function ad_audio_button(ele,is_stop){ var $self = $(ele); var button_container = $self.parents('.ba-banner-widget-youtube').eq(0); + var append_class = ""; if (is_stop){ button_container.find('.jarallax-video-audio').remove(); + var control_play_btn = $('.jarallax-video-control-play'); + if(control_play_btn.length){ + control_play_btn_pause.call(control_play_btn); + } }else{ + var control_play_btn = null; + if(window.accessibility_mode){ + append_class = " accessibility_mode_btn"; + var control_play_btn = $('.jarallax-video-control-play'); + if(control_play_btn.length){ + + control_play_btn_play.call(control_play_btn); + control_play_btn = null; + }else{ + control_play_btn = $(''); + } + } var audio_div; if ($self.hasClass('have-audio')){ - audio_div = $(''); + audio_div = $(''); }else{ - audio_div = $(''); + audio_div = $(''); } audio_div.find('p').css('display','none'); //fix CSP audio_div.click(function(event) { @@ -79,7 +108,47 @@ }); button_container.find('.jarallax-video-audio').remove(); button_container.append(audio_div); + if(control_play_btn != null){ + audio_div.after(control_play_btn); + control_play_btn.click(function(){ + var cycle_slideshow = button_container.find('.cycle-slideshow'); + var opts = cycle_slideshow.data('cycle.opts'); + var active_slide = opts.slides.filter('.'+opts.slideActiveClass); + if(active_slide.length){ + var yt_iframe = active_slide.find('iframe'); + if(yt_iframe.length == 0){ + var jplayer = active_slide.find('.jp-jplayer').data('jPlayer'); + if(jplayer){ + if(jplayer.htmlElement.video.paused){ + jplayer.play(); + }else{ + jplayer.pause(); + } + } + }else{ + if(window.yt_players){ + var subpart_id = button_container.attr('data-subpart-id'); + var subpart_yt_players = window.yt_players[subpart_id]; + if(subpart_yt_players){ + var yt_player = subpart_yt_players[yt_iframe.attr('id')]; + var play_state = yt_player.getPlayerState(); + if(play_state == YT.PlayerState.PLAYING || play_state == YT.PlayerState.BUFFERING){ + yt_player.pauseVideo(); + }else if(play_state == YT.PlayerState.UNSTARTED || play_state == YT.PlayerState.PAUSED || play_state == YT.PlayerState.ENDED || play_state == YT.PlayerState.CUED){ + yt_player.playVideo(); + play_state = yt_player.getPlayerState(); + if(play_state == YT.PlayerState.UNSTARTED || play_state == YT.PlayerState.PAUSED || play_state == YT.PlayerState.ENDED || play_state == YT.PlayerState.CUED){ + yt_player.mute().playVideo(); + } + } + } + } + } + } + }) + } } + } if(document.getElementById("youtube-iframe-api") == null){ var tag = document.createElement('script'); @@ -347,7 +416,7 @@ if (typeof onYouTubeIframeAPIReady !== 'function'){ })