From b4859dfaa4f82ee1b6f73c8f4bc7b00dcfc45e4e Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Wed, 3 May 2023 11:14:31 +0800 Subject: [PATCH] Fix bug. --- app/controllers/ad_banners_controller.rb | 2 +- modules/ad_banner/_ad_banner_widget2_video.html.erb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb index e6bc2db..19c2993 100644 --- a/app/controllers/ad_banners_controller.rb +++ b/app/controllers/ad_banners_controller.rb @@ -183,7 +183,7 @@ class AdBannersController < ApplicationController } } }", - "extra_document_ready_script" => ((@autoplay_video == "1") ? "opts.API.pause() && opts.API.jump(0);" : "") + "extra_document_ready_script" => ((@autoplay_video == "1") ? "(opts.slides.eq(0).find('iframe,.jp-jplayer').length != 0) && opts.API.pause() && opts.API.jump(0);" : "") }, "images" => images } diff --git a/modules/ad_banner/_ad_banner_widget2_video.html.erb b/modules/ad_banner/_ad_banner_widget2_video.html.erb index 5d45b10..af10773 100644 --- a/modules/ad_banner/_ad_banner_widget2_video.html.erb +++ b/modules/ad_banner/_ad_banner_widget2_video.html.erb @@ -327,6 +327,9 @@ event_dict[count_key] = event_dict[array_key].length; yt_player.addEventListener('onStateChange',onPlayerStateChange); banner_wrap.trigger('resize'); + if(i == 0 && $iframe.parents(".youtube_slide[data-autoplay=\"1\"]").length != 0){ + yt_player.mute().playVideo(); + } }else{ console.log("YT player changes its variables!") }