adbanner-test/app/views/admin/ad_images/_jplayer.html.erb

438 lines
14 KiB
Plaintext
Raw Normal View History

2022-01-03 11:56:30 +00:00
<%= javascript_include_tag "banner/jplayer_front" %>
<style type="text/css">
@media screen and (max-width: 500px) {
/* jplayer */
.jp-video video, .jp-audio, .jp-controls-holder {
width: 100% !important;
}
.jp-video-360p {
max-width: 570px !important;
}
.jp-video-270p {
max-width: 480px !important;
}
.jp-progress {
width: 130px;
}
}
.jp-interface{
bottom: 0;
height: 6em;
position: absolute;
}
.jp-video-play,.jp-jplayer{
height: 100%;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding-bottom: 6em;
}
.jp-gui{
width: 100%;
height: 100%;
}
.jp-jplayer{
width: 100%;
position: absolute;
2021-10-12 04:47:25 +00:00
overflow: hidden;
clip-path: 0 0;
box-sizing: content-box;
transform: translatez(0);
}
.jp-type-single{
position: relative;
height: 100%;
}
.jp-video{
width: 100%;
height: 100%;
}
[id^="jp_video_"]{
2021-10-12 04:47:25 +00:00
box-sizing: content-box;
position: absolute;
top: -100%;
bottom: -100%;
left: -100%;
right: -100%;
margin: auto;
2021-10-13 09:18:35 +00:00
2021-10-12 04:47:25 +00:00
min-width: 100%;
min-height: 100%;
2021-10-12 10:30:05 +00:00
object-fit: cover;
2021-10-12 04:47:25 +00:00
transform: translatez(0);
}
.jp-video.hide-ui .jp-jplayer,.jp-video.hide-ui .jp-video-play{
padding-bottom: 0em;
}
.jp-video.hide-ui .jp-gui{
display: none;
}
.jp-video.hide-ui [id^="jp_video_"]{
cursor: none;
}
2021-09-15 15:30:09 +00:00
.jp-video.hide-ui.auto_play [id^="jp_video_"]{
cursor: default;
}
.jp-no-solution
position: absolute;
width: 100%;
display: block;
}
</style>
2021-09-15 15:30:09 +00:00
<div id="jp_container_<%= i %>" class="jp-video hide-ui<%= " auto_play" if @autoplay_video%>" role="application" aria-label="media player">
<div class="jp-type-single">
<div id="jquery_jplayer_<%= i %>" class="jp-jplayer"></div>
<div class="jp-gui">
<div class="jp-video-play">
<button class="jp-video-play-icon" role="button" tabindex="0">play</button>
</div>
<div class="jp-interface">
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-current-time" role="timer" aria-label="time">&nbsp;</div>
<div class="jp-duration" role="timer" aria-label="duration">&nbsp;</div>
<div class="jp-controls-holder">
<div class="jp-controls">
<button class="jp-play" role="button" tabindex="0">play</button>
<button class="jp-stop" role="button" tabindex="0">stop</button>
</div>
<div class="jp-volume-controls">
<button class="jp-mute" role="button" tabindex="0">mute</button>
<button class="jp-volume-max" role="button" tabindex="0">max volume</button>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
</div>
<div class="jp-toggles">
<button class="jp-repeat" role="button" tabindex="0">repeat</button>
<button class="jp-full-screen" role="button" tabindex="0">full screen</button>
</div>
</div>
<div class="jp-details">
<div class="jp-title" aria-label="title">&nbsp;</div>
</div>
</div>
</div>
<div class="jp-no-solution">
<span>Update Required</span>
To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
</div>
</div>
</div>
<script type="text/javascript">
if (typeof(get_video_type)=='undefined'){
function get_video_type(file_name){
var type;
if(file_name){
if(file_name.match(/\.(ogg|ogv)/)){
type = "ogv";
}else if(file_name.match(/\.webm/)){
type = "webmv";
}else{
type = "m4v";
}
return type;
}else{
return "";
}
}
}
var play_<%= i %>_flag = false;
function ad_call_on_play_jplayer_<%= i %>(ele){
var cyclediv = $(ele).parents("div.cycle-slideshow").eq(0);
if(cyclediv.length == 1){
cyclediv[0].need_resume = !(cyclediv.hasClass("cycle-paused"));
var widget = cyclediv.parents('.w-ba-banner').eq(0);
widget.find(".pause-slide").trigger('click');
widget.find('.banner-pager,.controlplay,.button-mid,.ad-overlay').css('visibility','hidden');
//$(ele).jPlayer("pauseOthers");
hide_jplayer_ui_<%= i %>(ele);
}
2021-11-14 04:43:46 +00:00
}
function ad_call_on_pause_jplayer_<%= i %>(ele){
var cyclediv = $(ele).parents("div.cycle-slideshow").eq(0);
if(cyclediv.length == 1){
var widget = cyclediv.parents('.w-ba-banner').eq(0);
if(cyclediv[0].need_resume){
widget.find(".resume-slide").trigger('click');
}
widget.find('.banner-pager,.controlplay,.button-mid,.ad-overlay').css('visibility','');
hide_jplayer_ui_<%= i %>(ele);
}
}
function hide_jplayer_ui_<%= i %>(ele) {
var jpalyer_video = $(ele).parents('.jp-video').eq(0);
jpalyer_video.find(".jp-gui").css("display","");
jpalyer_video.addClass('hide-ui');
}
function show_jplayer_ui_<%= i %>(ele) {
<% unless @hide_video_tools %>
var jpalyer_video = $(ele).parents('.jp-video').eq(0);
jpalyer_video.removeClass('hide-ui');
<% end %>
}
function click_jplayer_<%= i %>(){
$("#jp_container_<%= i %> .jp-video-play").css('display','')
if (play_<%= i %>_flag){
$("#jquery_jplayer_<%= i %>").jPlayer("pause");
}else{
$("#jquery_jplayer_<%= i %>").jPlayer("play");
}
<% unless @hide_video_tools %>
$(this).parents('.jp-video').eq(0).removeClass('hide-ui');
<% end %>
}
2021-08-31 06:15:12 +00:00
function jplayer_center_video_front(ele){
2021-10-12 04:47:25 +00:00
/*
2021-09-02 05:38:12 +00:00
$(ele).css('margin-left',-Math.abs($(ele).parent().width()-$(ele).width())/2);
2021-08-31 06:15:12 +00:00
if($(ele).parents('.w-ba-banner').length>0){
2021-10-12 04:47:25 +00:00
var p_h = $(ele).parents('.w-ba-banner').eq(-1).height();
var h = ele.videoHeight || $(ele).height();
$(ele).height()
$(ele).css('margin-top',-Math.abs(p_h-h)/2);
2021-08-31 06:15:12 +00:00
}
$(ele).css('transform','unset');
2021-10-12 04:47:25 +00:00
*/
2021-08-31 06:15:12 +00:00
}
$(window).resize(function() {
$('.w-ba-banner video[id^=jp_video_]').each(function(){
jplayer_center_video_front(this);
});
})
if (typeof(default_video_data)=='undefined'){
var default_video_data = {
2022-08-21 08:43:10 +00:00
cssSelectorAncestor: "#jp_container_<%= i %>",
ready: function () {
2022-08-21 08:43:10 +00:00
$(this).jPlayer("setMedia", {
title: "Big Buck Bunny Trailer",
m4v: "http://www.jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v",
ogv: "http://www.jplayer.org/video/ogv/Big_Buck_Bunny_Trailer.ogv",
webmv: "http://www.jplayer.org/video/webm/Big_Buck_Bunny_Trailer.webm",
poster: "http://www.jplayer.org/video/poster/Big_Buck_Bunny_Trailer_480x270.png"
})
},
play: function() { // To avoid multiple jPlayers playing together.
play_<%= i %>_flag = true;
ad_call_on_play_jplayer_<%= i %>(this);
2021-08-31 06:18:46 +00:00
jplayer_center_video_front($(this).find('video'));
2021-11-14 05:12:33 +00:00
<% if @hide_video_tools %>
2021-11-14 05:14:32 +00:00
ad_audio_button(this,false);
2021-11-14 05:12:33 +00:00
<% end %>
var is_frontend = <%= @is_frontend ? true : false %>;
if(is_frontend){
var cyclediv = $(this).parents("div.cycle-slideshow").eq(0);
2022-03-07 11:25:29 +00:00
cyclediv.css("padding-bottom",'');
if(cyclediv.height() == 0 || cyclediv.data("auto-height")){
cyclediv.data("auto-height",true);
var video_block = cyclediv.find('video')[0];
if(video_block != undefined){
cyclediv.height(cyclediv.width() * video_block.videoHeight / video_block.videoWidth);
if(!(cyclediv.data("bind-resize"))){
cyclediv.data("bind-resize",true);
$(window).resize(function(){
cyclediv.height(cyclediv.width() * video_block.videoHeight / video_block.videoWidth);
})
}
}
}
}
},
click: function(){
click_jplayer_<%= i %>();
},
pause: function(){
play_<%= i %>_flag = false;
$(this).jPlayer("pause");
ad_call_on_pause_jplayer_<%= i %>(this);
window.console.log("pause");
2021-11-14 05:14:32 +00:00
ad_audio_button(this,true);
},
abort: function(){
play_<%= i %>_flag = false;
<% unless @hide_video_tools %>
$(this).parents('.jp-video').eq(0).removeClass('hide-ui');
<% end %>
window.console.log("abort");
},
ended: function(){
play_<%= i %>_flag = false;
<% unless @hide_video_tools %>
$(this).parents('.jp-video').eq(0).removeClass('hide-ui');
<% end %>
<% if @apply_autoplay_script %>
2021-11-10 04:01:02 +00:00
var is_frontend = <%= @is_frontend ? true : false %>;
var cyclediv = $(this).parents("div.cycle-slideshow").eq(0);
var autoHeight = cyclediv.data("auto-height");
2021-11-10 04:01:02 +00:00
if(!is_frontend || (is_frontend && cyclediv.find('[data-autoplay=1]').length != 0)){
cyclediv.cycle("pause").cycle("next");
2022-01-01 03:22:47 +00:00
var current_cycle = cyclediv.find(".cycle-slide-active");
if(current_cycle.hasClass("jplayer_slide")){
var $video_ele = current_cycle.find('.jp-jplayer video');
if ($video_ele.length>0){
2022-01-03 14:08:00 +00:00
$video_ele.eq(0).attr('muted','muted').attr('autoplay','autoplay').attr('playsinline',true);
2022-01-01 03:22:47 +00:00
}
2021-11-10 04:01:02 +00:00
current_cycle.find('.jp-jplayer').jPlayer("mute", true).jPlayer("play",0);
2022-01-01 03:22:47 +00:00
}
2021-11-14 05:28:44 +00:00
else if(current_cycle.find('iframe').length>0){
2021-11-10 04:01:02 +00:00
current_cycle.find('iframe').data("yt_player").mute().playVideo();
2021-11-14 05:28:44 +00:00
}
2021-11-10 04:01:02 +00:00
}
<% end %>
window.console.log("end");
},
2022-01-03 11:56:30 +00:00
swfPath: "/assets/banner",
supplied: "webmv, ogv, m4v",
globalVolume: true,
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
2021-10-13 09:18:35 +00:00
preload: 'auto',
2021-08-11 08:49:16 +00:00
keyBindings: {
play: {
key: 80, // p
fn: function(f) {
if(f.status.paused) {
f.play();
} else {
f.pause();
}
}
},
2021-10-13 09:18:35 +00:00
fullScreen: {
key: 70, // f
fn: function(f) {
if(f.status.video || f.options.audioFullScreen) {
f._setOption("fullScreen", !f.options.fullScreen);
}
}
},
2021-08-11 08:49:16 +00:00
muted: {
key: 77, // m
fn: function(f) {
f._muted(!f.options.muted);
}
},
volumeUp: {
key: 190, // .
fn: function(f) {
f.volume(f.options.volume + 0.1);
}
},
volumeDown: {
key: 188, // ,
fn: function(f) {
f.volume(f.options.volume - 0.1);
}
},
loop: {
key: 76, // l
fn: function(f) {
f._loop(!f.options.loop);
}
}
2021-08-13 01:52:19 +00:00
},
wmode: "window",
solution: "html, flash",
size: {
width: "100%",
height: "",
cssClass: ""
}
};
}
<% if file_url %>
var jPlayer_<%= i %>_name = "<%= file_name %>";
var jPlayer_<%= i %>_type = get_video_type(jPlayer_<%= i %>_name);
var jPlayer_<%= i %>_data = {
title: jPlayer_<%= i %>_name,
};
var jPlayer_<%= i %> = $.extend({},default_video_data);
jPlayer_<%= i %>_data[jPlayer_<%= i %>_type] = "<%= file_url %>";
2021-10-22 15:31:10 +00:00
<% if file_webm_url %>
jPlayer_<%= i %>_data['webmv'] = "<%= file_webm_url %>";
<% end %>
2022-01-05 07:52:40 +00:00
<% if @file_poster %>
jPlayer_<%= i %>_data['poster'] = "<%= @file_poster %>";
<% end %>
//jPlayer_<%= i %>_data["autoPlay"] = <%= @autoplay_video == true %>;
jPlayer_<%= i %>["ready"] = function () {
$(this).jPlayer("setMedia", jPlayer_<%= i %>_data);
2022-08-21 08:43:10 +00:00
var slides = $(this).parents('.cycle-slideshow').data('cycle.opts').slides;
if (slides && slides.index($(this).parents(".w-ba-banner__slide").eq(0))==0){
2021-11-15 04:57:04 +00:00
<% if @autoplay_video == true %>
2022-01-01 03:22:47 +00:00
var $video_ele = $(this).find('video');
if ($video_ele.length>0){
$video_ele.eq(0).attr('autoplay','autoplay').attr('muted','muted').attr('playsinline',true);
}
2021-11-15 04:57:04 +00:00
$(this).jPlayer("mute", true).jPlayer("play",0);
<% end %>
}
<% unless @hide_video_tools %>
$(this).parents('.jp-video').eq(0).removeClass('hide-ui');
<% end %>
}
<% else %>
var jPlayer_<%= i %> = default_video_data;
<% end %>
2022-10-04 05:14:34 +00:00
function jplayer_ready_func_<%= i %>(){
$("#jquery_jplayer_<%= i %>").jPlayer(jPlayer_<%= i %>);
if ($("#jquery_jplayer_<%= i %>").parents("div.cycle-slideshow").length>0){
$("#jquery_jplayer_<%= i %>").addClass("hide-ui");
}
2022-07-04 09:47:28 +00:00
$("#jquery_jplayer_<%= i %>, #jquery_jplayer_<%= i %> +.jp-gui .jp-video-play-icon").click(function(event){
click_jplayer_<%= i %>();
2021-11-15 07:25:08 +00:00
//event.stopPropagation();
})
$("#jquery_jplayer_<%= i %> *[id^='jp_video'],#jquery_jplayer_<%= i %>").mouseover(function( event ) {
var $this = $(this);
var wrapper = $this.parents('.jp-video').eq(0)
var video_item;
try{
video_item = $this.data('jPlayer').internal.video.jq;
}catch(e){};
if(video_item)
video_item.removeAttr('title');
<% unless @hide_video_tools %>
wrapper.removeClass('hide-ui');
<% end %>
});
function mousemove(target,callback_move,callback_stop) {
target = target || window;
$(target).mousemove((function(event) {
var t;
return function(event) {
if(typeof t !='undefined')
clearTimeout(t);
var _this = event.target;
if(callback_move){
t = setTimeout(function() {callback_move.call(_this,_this)},0);
}
if(callback_stop){
t = setTimeout(function() {
if(typeof t !='undefined'){
clearTimeout(t);
}
callback_stop.call(_this,_this);
}, 1000)
}
}
})())
}
mousemove("#jquery_jplayer_<%= i %> *[id^='jp_video'],#jquery_jplayer_<%= i %>",show_jplayer_ui_<%= i %>,hide_jplayer_ui_<%= i %>)
}
<% if defined?(not_ready).nil? || !not_ready %>
$(document).ready(function(){
2022-10-04 05:14:34 +00:00
jplayer_ready_func_<%= i %>();
})
<% end %>
2021-09-02 05:16:24 +00:00
</script>