From 600d0d94b824d25d76763ca05d8b61ef82f9270c Mon Sep 17 00:00:00 2001 From: Bohung Date: Wed, 10 Nov 2021 12:01:02 +0800 Subject: [PATCH] Fix frontend autoplay bug. --- app/controllers/ad_banners_controller.rb | 12 +++++++----- app/views/admin/ad_images/_jplayer.html.erb | 15 +++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb index 4eb82fd..515bab3 100644 --- a/app/controllers/ad_banners_controller.rb +++ b/app/controllers/ad_banners_controller.rb @@ -67,7 +67,7 @@ class AdBannersController < ApplicationController def video_widget(adbanner) subpart = OrbitHelper.get_current_widget custom_data_field = subpart.custom_data_field || {} - @autoplay_video = custom_data_field[:autoplay_video] == "1" rescue false + @autoplay_video = custom_data_field[:autoplay_video] rescue "0" @hide_video_tools = custom_data_field[:hide_video_tools] == "1" rescue false images = [] has_jplayer = false @@ -109,8 +109,9 @@ class AdBannersController < ApplicationController data-overlay-template=\"

#{ad_b.title}

#{context}

\" data-target=\"#{target}\" style=\"height: 100%;\" + data-autoplay=\"#{@autoplay_video}\" > - #{ render_to_string(partial: "admin/ad_images/jplayer",locals:{i: i,file_name: title,file_url: video_url,file_webm_url: video_webm_url,:@autoplay_video=>(@autoplay_video && i == 0),:@apply_autoplay_script=>@autoplay_video,:@hide_video_tools=>@hide_video_tools}, layout: false).to_str } + #{ render_to_string(partial: "admin/ad_images/jplayer",locals:{i: (subpart.id.to_s+i.to_s),file_name: title,file_url: video_url,file_webm_url: video_webm_url,:@autoplay_video=>(@autoplay_video == "1" && i == 0),:@apply_autoplay_script=>true,:@hide_video_tools=>@hide_video_tools,:@is_frontend=>true}, layout: false).to_str } " has_jplayer = true elsif ad_b.exchange_item == "2" @@ -123,6 +124,7 @@ class AdBannersController < ApplicationController data-cycle-desc=\"#{context}\" data-overlay-template=\"

#{ad_b.title}

#{context}

\" data-target=\"#{target}\" + data-autoplay=\"#{@autoplay_video}\" >