commit 28bd3dd7665a3307f1d75a2ce9133ead5f54ead6 Author: BoHung Chiu Date: Thu Feb 2 14:42:50 2023 +0800 First version. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..de5d954 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.bundle/ +log/*.log +pkg/ +test/dummy/db/*.sqlite3 +test/dummy/db/*.sqlite3-journal +test/dummy/log/*.log +test/dummy/tmp/ +test/dummy/.sass-cache diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..9ed96ee --- /dev/null +++ b/Gemfile @@ -0,0 +1,14 @@ +source "https://rubygems.org" + +# Declare your gem's dependencies in video_pro.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use debugger +# gem 'debugger' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..0dd3349 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,104 @@ +PATH + remote: . + specs: + video_pro (0.0.1) + mongoid (= 4.0.0.beta1) + rails (~> 4.1.0.rc2) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.1.0) + actionpack (= 4.1.0) + actionview (= 4.1.0) + mail (~> 2.5.4) + actionpack (4.1.0) + actionview (= 4.1.0) + activesupport (= 4.1.0) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.0) + activesupport (= 4.1.0) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.0) + activesupport (= 4.1.0) + builder (~> 3.1) + activerecord (4.1.0) + activemodel (= 4.1.0) + activesupport (= 4.1.0) + arel (~> 5.0.0) + activesupport (4.1.0) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + arel (5.0.0) + bson (2.2.2) + builder (3.2.2) + connection_pool (2.0.0) + erubis (2.7.0) + hike (1.2.3) + i18n (0.6.9) + json (1.8.1) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.25.1) + minitest (5.3.2) + mongoid (4.0.0.beta1) + activemodel (>= 4.0.0) + moped (~> 2.0.beta6) + origin (~> 2.1) + tzinfo (>= 0.3.37) + moped (2.0.0.rc1) + bson (~> 2.2) + connection_pool (~> 2.0) + optionable (~> 0.2.0) + multi_json (1.9.2) + optionable (0.2.0) + origin (2.1.1) + polyglot (0.3.4) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rails (4.1.0) + actionmailer (= 4.1.0) + actionpack (= 4.1.0) + actionview (= 4.1.0) + activemodel (= 4.1.0) + activerecord (= 4.1.0) + activesupport (= 4.1.0) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.0) + sprockets-rails (~> 2.0) + railties (4.1.0) + actionpack (= 4.1.0) + activesupport (= 4.1.0) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.2.2) + sprockets (2.12.0) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.1.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + thor (0.19.1) + thread_safe (0.3.3) + tilt (1.4.1) + treetop (1.4.15) + polyglot + polyglot (>= 0.3.1) + tzinfo (1.1.0) + thread_safe (~> 0.1) + +PLATFORMS + ruby + +DEPENDENCIES + video_pro! diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..ea966ec --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2014 YOURNAME + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..86aaac7 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += VideoPro + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..e1a3203 --- /dev/null +++ b/Rakefile @@ -0,0 +1,32 @@ +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end + +require 'rdoc/task' + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'VideoPro' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + + + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task default: :test diff --git a/app/assets/images/jplayer.blue.monday.jpg b/app/assets/images/jplayer.blue.monday.jpg new file mode 100644 index 0000000..adab53f Binary files /dev/null and b/app/assets/images/jplayer.blue.monday.jpg differ diff --git a/app/assets/images/jplayer.blue.monday.seeking.gif b/app/assets/images/jplayer.blue.monday.seeking.gif new file mode 100644 index 0000000..dbd2105 Binary files /dev/null and b/app/assets/images/jplayer.blue.monday.seeking.gif differ diff --git a/app/assets/images/jplayer.blue.monday.video.pause.png b/app/assets/images/jplayer.blue.monday.video.pause.png new file mode 100644 index 0000000..682c343 Binary files /dev/null and b/app/assets/images/jplayer.blue.monday.video.pause.png differ diff --git a/app/assets/images/jplayer.blue.monday.video.play.png b/app/assets/images/jplayer.blue.monday.video.play.png new file mode 100644 index 0000000..8e97df0 Binary files /dev/null and b/app/assets/images/jplayer.blue.monday.video.play.png differ diff --git a/app/assets/images/slideshow_preview_A.png b/app/assets/images/slideshow_preview_A.png new file mode 100644 index 0000000..25a42a3 Binary files /dev/null and b/app/assets/images/slideshow_preview_A.png differ diff --git a/app/assets/images/slideshow_preview_B.png b/app/assets/images/slideshow_preview_B.png new file mode 100644 index 0000000..1d40e65 Binary files /dev/null and b/app/assets/images/slideshow_preview_B.png differ diff --git a/app/assets/images/video_pro/.keep b/app/assets/images/video_pro/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/images/video_pro/btn-play.png b/app/assets/images/video_pro/btn-play.png new file mode 100644 index 0000000..b1154b5 Binary files /dev/null and b/app/assets/images/video_pro/btn-play.png differ diff --git a/app/assets/images/video_pro/icon_hd.png b/app/assets/images/video_pro/icon_hd.png new file mode 100644 index 0000000..3adfcc9 Binary files /dev/null and b/app/assets/images/video_pro/icon_hd.png differ diff --git a/app/assets/images/video_pro/icon_view.png b/app/assets/images/video_pro/icon_view.png new file mode 100644 index 0000000..7581e0d Binary files /dev/null and b/app/assets/images/video_pro/icon_view.png differ diff --git a/app/assets/images/video_pro/search_btn.png b/app/assets/images/video_pro/search_btn.png new file mode 100644 index 0000000..1749456 Binary files /dev/null and b/app/assets/images/video_pro/search_btn.png differ diff --git a/app/assets/javascripts/admin/video_pros.js b/app/assets/javascripts/admin/video_pros.js new file mode 100644 index 0000000..f80429e --- /dev/null +++ b/app/assets/javascripts/admin/video_pros.js @@ -0,0 +1,21 @@ +$(function() { + $.pageslide.closeCallback(function(pageslide, item) { + $("tr").removeClass("active"); + pageslide.find('.preview').cycle('destroy'); + }); + $.pageslide.loadComplete(function(pageslide, item) { + $("tr").removeClass("active"); + item.closest('tr').addClass('active'); + if(item.data('id') == 'new') { + resetForm(); + pageslide.find('form').attr('action', '/admin/video_pros/'); + pageslide.find('form').attr('method', 'post'); + } + else { + setForm(item.data('form')); + pageslide.find('form').attr('action', '/admin/video_pros/' + item.data('id')); + pageslide.find('form').attr('method', 'put'); + } + setSlideshow(pageslide.find('.preview'), item.data()); + }); +}) \ No newline at end of file diff --git a/app/assets/javascripts/cycle2.js b/app/assets/javascripts/cycle2.js new file mode 100644 index 0000000..60bea42 --- /dev/null +++ b/app/assets/javascripts/cycle2.js @@ -0,0 +1,4 @@ +//= require cycle2/jquery.cycle2.min.js +//= require cycle2/transition/jquery.cycle2.flip.min.js +//= require cycle2/transition/jquery.cycle2.scrollVert.min.js +//= require cycle2/transition/jquery.cycle2.tile.min.js \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/jquery.cycle2.min.js b/app/assets/javascripts/cycle2/jquery.cycle2.min.js new file mode 100644 index 0000000..9f9ec0f --- /dev/null +++ b/app/assets/javascripts/cycle2/jquery.cycle2.min.js @@ -0,0 +1,17 @@ +/*! +* jQuery Cycle2; build: v20131005 +* http://jquery.malsup.com/cycle2/ +* Copyright (c) 2013 M. Alsup; Dual licensed: MIT/GPL +*/ +/*! core engine; version: 20131003 */ +(function(e){"use strict";function t(e){return(e||"").toLowerCase()}var i="20131003";e.fn.cycle=function(i){var n;return 0!==this.length||e.isReady?this.each(function(){var n,s,o,c,r=e(this),l=e.fn.cycle.log;if(!r.data("cycle.opts")){(r.data("cycle-log")===!1||i&&i.log===!1||s&&s.log===!1)&&(l=e.noop),l("--c2 init--"),n=r.data();for(var a in n)n.hasOwnProperty(a)&&/^cycle[A-Z]+/.test(a)&&(c=n[a],o=a.match(/^cycle(.*)/)[1].replace(/^[A-Z]/,t),l(o+":",c,"("+typeof c+")"),n[o]=c);s=e.extend({},e.fn.cycle.defaults,n,i||{}),s.timeoutId=0,s.paused=s.paused||!1,s.container=r,s._maxZ=s.maxZ,s.API=e.extend({_container:r},e.fn.cycle.API),s.API.log=l,s.API.trigger=function(e,t){return s.container.trigger(e,t),s.API},r.data("cycle.opts",s),r.data("cycle.API",s.API),s.API.trigger("cycle-bootstrap",[s,s.API]),s.API.addInitialSlides(),s.API.preInitSlideshow(),s.slides.length&&s.API.initSlideshow()}}):(n={s:this.selector,c:this.context},e.fn.cycle.log("requeuing slideshow (dom not ready)"),e(function(){e(n.s,n.c).cycle(i)}),this)},e.fn.cycle.API={opts:function(){return this._container.data("cycle.opts")},addInitialSlides:function(){var t=this.opts(),i=t.slides;t.slideCount=0,t.slides=e(),i=i.jquery?i:t.container.find(i),t.random&&i.sort(function(){return Math.random()-.5}),t.API.add(i)},preInitSlideshow:function(){var t=this.opts();t.API.trigger("cycle-pre-initialize",[t]);var i=e.fn.cycle.transitions[t.fx];i&&e.isFunction(i.preInit)&&i.preInit(t),t._preInitialized=!0},postInitSlideshow:function(){var t=this.opts();t.API.trigger("cycle-post-initialize",[t]);var i=e.fn.cycle.transitions[t.fx];i&&e.isFunction(i.postInit)&&i.postInit(t)},initSlideshow:function(){var t,i=this.opts(),n=i.container;i.API.calcFirstSlide(),"static"==i.container.css("position")&&i.container.css("position","relative"),e(i.slides[i.currSlide]).css("opacity",1).show(),i.API.stackSlides(i.slides[i.currSlide],i.slides[i.nextSlide],!i.reverse),i.pauseOnHover&&(i.pauseOnHover!==!0&&(n=e(i.pauseOnHover)),n.hover(function(){i.API.pause(!0)},function(){i.API.resume(!0)})),i.timeout&&(t=i.API.getSlideOpts(i.currSlide),i.API.queueTransition(t,t.timeout+i.delay)),i._initialized=!0,i.API.updateView(!0),i.API.trigger("cycle-initialized",[i]),i.API.postInitSlideshow()},pause:function(t){var i=this.opts(),n=i.API.getSlideOpts(),s=i.hoverPaused||i.paused;t?i.hoverPaused=!0:i.paused=!0,s||(i.container.addClass("cycle-paused"),i.API.trigger("cycle-paused",[i]).log("cycle-paused"),n.timeout&&(clearTimeout(i.timeoutId),i.timeoutId=0,i._remainingTimeout-=e.now()-i._lastQueue,(0>i._remainingTimeout||isNaN(i._remainingTimeout))&&(i._remainingTimeout=void 0)))},resume:function(e){var t=this.opts(),i=!t.hoverPaused&&!t.paused;e?t.hoverPaused=!1:t.paused=!1,i||(t.container.removeClass("cycle-paused"),0===t.slides.filter(":animated").length&&t.API.queueTransition(t.API.getSlideOpts(),t._remainingTimeout),t.API.trigger("cycle-resumed",[t,t._remainingTimeout]).log("cycle-resumed"))},add:function(t,i){var n,s=this.opts(),o=s.slideCount,c=!1;"string"==e.type(t)&&(t=e.trim(t)),e(t).each(function(){var t,n=e(this);i?s.container.prepend(n):s.container.append(n),s.slideCount++,t=s.API.buildSlideOpts(n),s.slides=i?e(n).add(s.slides):s.slides.add(n),s.API.initSlide(t,n,--s._maxZ),n.data("cycle.opts",t),s.API.trigger("cycle-slide-added",[s,t,n])}),s.API.updateView(!0),c=s._preInitialized&&2>o&&s.slideCount>=1,c&&(s._initialized?s.timeout&&(n=s.slides.length,s.nextSlide=s.reverse?n-1:1,s.timeoutId||s.API.queueTransition(s)):s.API.initSlideshow())},calcFirstSlide:function(){var e,t=this.opts();e=parseInt(t.startingSlide||0,10),(e>=t.slides.length||0>e)&&(e=0),t.currSlide=e,t.reverse?(t.nextSlide=e-1,0>t.nextSlide&&(t.nextSlide=t.slides.length-1)):(t.nextSlide=e+1,t.nextSlide==t.slides.length&&(t.nextSlide=0))},calcNextSlide:function(){var e,t=this.opts();t.reverse?(e=0>t.nextSlide-1,t.nextSlide=e?t.slideCount-1:t.nextSlide-1,t.currSlide=e?0:t.nextSlide+1):(e=t.nextSlide+1==t.slides.length,t.nextSlide=e?0:t.nextSlide+1,t.currSlide=e?t.slides.length-1:t.nextSlide-1)},calcTx:function(t,i){var n,s=t;return i&&s.manualFx&&(n=e.fn.cycle.transitions[s.manualFx]),n||(n=e.fn.cycle.transitions[s.fx]),n||(n=e.fn.cycle.transitions.fade,s.API.log('Transition "'+s.fx+'" not found. Using fade.')),n},prepareTx:function(e,t){var i,n,s,o,c,r=this.opts();return 2>r.slideCount?(r.timeoutId=0,void 0):(!e||r.busy&&!r.manualTrump||(r.API.stopTransition(),r.busy=!1,clearTimeout(r.timeoutId),r.timeoutId=0),r.busy||(0!==r.timeoutId||e)&&(n=r.slides[r.currSlide],s=r.slides[r.nextSlide],o=r.API.getSlideOpts(r.nextSlide),c=r.API.calcTx(o,e),r._tx=c,e&&void 0!==o.manualSpeed&&(o.speed=o.manualSpeed),r.nextSlide!=r.currSlide&&(e||!r.paused&&!r.hoverPaused&&r.timeout)?(r.API.trigger("cycle-before",[o,n,s,t]),c.before&&c.before(o,n,s,t),i=function(){r.busy=!1,r.container.data("cycle.opts")&&(c.after&&c.after(o,n,s,t),r.API.trigger("cycle-after",[o,n,s,t]),r.API.queueTransition(o),r.API.updateView(!0))},r.busy=!0,c.transition?c.transition(o,n,s,t,i):r.API.doTransition(o,n,s,t,i),r.API.calcNextSlide(),r.API.updateView()):r.API.queueTransition(o)),void 0)},doTransition:function(t,i,n,s,o){var c=t,r=e(i),l=e(n),a=function(){l.animate(c.animIn||{opacity:1},c.speed,c.easeIn||c.easing,o)};l.css(c.cssBefore||{}),r.animate(c.animOut||{},c.speed,c.easeOut||c.easing,function(){r.css(c.cssAfter||{}),c.sync||a()}),c.sync&&a()},queueTransition:function(t,i){var n=this.opts(),s=void 0!==i?i:t.timeout;return 0===n.nextSlide&&0===--n.loop?(n.API.log("terminating; loop=0"),n.timeout=0,s?setTimeout(function(){n.API.trigger("cycle-finished",[n])},s):n.API.trigger("cycle-finished",[n]),n.nextSlide=n.currSlide,void 0):(s&&(n._lastQueue=e.now(),void 0===i&&(n._remainingTimeout=t.timeout),n.paused||n.hoverPaused||(n.timeoutId=setTimeout(function(){n.API.prepareTx(!1,!n.reverse)},s))),void 0)},stopTransition:function(){var e=this.opts();e.slides.filter(":animated").length&&(e.slides.stop(!1,!0),e.API.trigger("cycle-transition-stopped",[e])),e._tx&&e._tx.stopTransition&&e._tx.stopTransition(e)},advanceSlide:function(e){var t=this.opts();return clearTimeout(t.timeoutId),t.timeoutId=0,t.nextSlide=t.currSlide+e,0>t.nextSlide?t.nextSlide=t.slides.length-1:t.nextSlide>=t.slides.length&&(t.nextSlide=0),t.API.prepareTx(!0,e>=0),!1},buildSlideOpts:function(i){var n,s,o=this.opts(),c=i.data()||{};for(var r in c)c.hasOwnProperty(r)&&/^cycle[A-Z]+/.test(r)&&(n=c[r],s=r.match(/^cycle(.*)/)[1].replace(/^[A-Z]/,t),o.API.log("["+(o.slideCount-1)+"]",s+":",n,"("+typeof n+")"),c[s]=n);c=e.extend({},e.fn.cycle.defaults,o,c),c.slideNum=o.slideCount;try{delete c.API,delete c.slideCount,delete c.currSlide,delete c.nextSlide,delete c.slides}catch(l){}return c},getSlideOpts:function(t){var i=this.opts();void 0===t&&(t=i.currSlide);var n=i.slides[t],s=e(n).data("cycle.opts");return e.extend({},i,s)},initSlide:function(t,i,n){var s=this.opts();i.css(t.slideCss||{}),n>0&&i.css("zIndex",n),isNaN(t.speed)&&(t.speed=e.fx.speeds[t.speed]||e.fx.speeds._default),t.sync||(t.speed=t.speed/2),i.addClass(s.slideClass)},updateView:function(e,t){var i=this.opts();if(i._initialized){var n=i.API.getSlideOpts(),s=i.slides[i.currSlide];!e&&t!==!0&&(i.API.trigger("cycle-update-view-before",[i,n,s]),0>i.updateView)||(i.slideActiveClass&&i.slides.removeClass(i.slideActiveClass).eq(i.currSlide).addClass(i.slideActiveClass),e&&i.hideNonActive&&i.slides.filter(":not(."+i.slideActiveClass+")").hide(),i.API.trigger("cycle-update-view",[i,n,s,e]),e&&i.API.trigger("cycle-update-view-after",[i,n,s]))}},getComponent:function(t){var i=this.opts(),n=i[t];return"string"==typeof n?/^\s*[\>|\+|~]/.test(n)?i.container.find(n):e(n):n.jquery?n:e(n)},stackSlides:function(t,i,n){var s=this.opts();t||(t=s.slides[s.currSlide],i=s.slides[s.nextSlide],n=!s.reverse),e(t).css("zIndex",s.maxZ);var o,c=s.maxZ-2,r=s.slideCount;if(n){for(o=s.currSlide+1;r>o;o++)e(s.slides[o]).css("zIndex",c--);for(o=0;s.currSlide>o;o++)e(s.slides[o]).css("zIndex",c--)}else{for(o=s.currSlide-1;o>=0;o--)e(s.slides[o]).css("zIndex",c--);for(o=r-1;o>s.currSlide;o--)e(s.slides[o]).css("zIndex",c--)}e(i).css("zIndex",s.maxZ-1)},getSlideIndex:function(e){return this.opts().slides.index(e)}},e.fn.cycle.log=function(){window.console&&console.log&&console.log("[cycle2] "+Array.prototype.join.call(arguments," "))},e.fn.cycle.version=function(){return"Cycle2: "+i},e.fn.cycle.transitions={custom:{},none:{before:function(e,t,i,n){e.API.stackSlides(i,t,n),e.cssBefore={opacity:1,display:"block"}}},fade:{before:function(t,i,n,s){var o=t.API.getSlideOpts(t.nextSlide).slideCss||{};t.API.stackSlides(i,n,s),t.cssBefore=e.extend(o,{opacity:0,display:"block"}),t.animIn={opacity:1},t.animOut={opacity:0}}},fadeout:{before:function(t,i,n,s){var o=t.API.getSlideOpts(t.nextSlide).slideCss||{};t.API.stackSlides(i,n,s),t.cssBefore=e.extend(o,{opacity:1,display:"block"}),t.animOut={opacity:0}}},scrollHorz:{before:function(e,t,i,n){e.API.stackSlides(t,i,n);var s=e.container.css("overflow","hidden").width();e.cssBefore={left:n?s:-s,top:0,opacity:1,display:"block"},e.cssAfter={zIndex:e._maxZ-2,left:0},e.animIn={left:0},e.animOut={left:n?-s:s}}}},e.fn.cycle.defaults={allowWrap:!0,autoSelector:".cycle-slideshow[data-cycle-auto-init!=false]",delay:0,easing:null,fx:"fade",hideNonActive:!0,loop:0,manualFx:void 0,manualSpeed:void 0,manualTrump:!0,maxZ:100,pauseOnHover:!1,reverse:!1,slideActiveClass:"cycle-slide-active",slideClass:"cycle-slide",slideCss:{position:"absolute",top:0,left:0},slides:"> img",speed:500,startingSlide:0,sync:!0,timeout:4e3,updateView:-1},e(document).ready(function(){e(e.fn.cycle.defaults.autoSelector).cycle()})})(jQuery),/*! Cycle2 autoheight plugin; Copyright (c) M.Alsup, 2012; version: 20130304 */ +function(e){"use strict";function t(t,n){var s,o,c,r=n.autoHeight;if("container"==r)o=e(n.slides[n.currSlide]).outerHeight(),n.container.height(o);else if(n._autoHeightRatio)n.container.height(n.container.width()/n._autoHeightRatio);else if("calc"===r||"number"==e.type(r)&&r>=0){if(c="calc"===r?i(t,n):r>=n.slides.length?0:r,c==n._sentinelIndex)return;n._sentinelIndex=c,n._sentinel&&n._sentinel.remove(),s=e(n.slides[c].cloneNode(!0)),s.removeAttr("id name rel").find("[id],[name],[rel]").removeAttr("id name rel"),s.css({position:"static",visibility:"hidden",display:"block"}).prependTo(n.container).addClass("cycle-sentinel cycle-slide").removeClass("cycle-slide-active"),s.find("*").css("visibility","hidden"),n._sentinel=s}}function i(t,i){var n=0,s=-1;return i.slides.each(function(t){var i=e(this).height();i>s&&(s=i,n=t)}),n}function n(t,i,n,s){var o=e(s).outerHeight(),c=i.sync?i.speed/2:i.speed;i.container.animate({height:o},c)}function s(i,o){o._autoHeightOnResize&&(e(window).off("resize orientationchange",o._autoHeightOnResize),o._autoHeightOnResize=null),o.container.off("cycle-slide-added cycle-slide-removed",t),o.container.off("cycle-destroyed",s),o.container.off("cycle-before",n),o._sentinel&&(o._sentinel.remove(),o._sentinel=null)}e.extend(e.fn.cycle.defaults,{autoHeight:0}),e(document).on("cycle-initialized",function(i,o){function c(){t(i,o)}var r,l=o.autoHeight,a=e.type(l),d=null;("string"===a||"number"===a)&&(o.container.on("cycle-slide-added cycle-slide-removed",t),o.container.on("cycle-destroyed",s),"container"==l?o.container.on("cycle-before",n):"string"===a&&/\d+\:\d+/.test(l)&&(r=l.match(/(\d+)\:(\d+)/),r=r[1]/r[2],o._autoHeightRatio=r),"number"!==a&&(o._autoHeightOnResize=function(){clearTimeout(d),d=setTimeout(c,50)},e(window).on("resize orientationchange",o._autoHeightOnResize)),setTimeout(c,30))})}(jQuery),/*! caption plugin for Cycle2; version: 20130306 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{caption:"> .cycle-caption",captionTemplate:"{{slideNum}} / {{slideCount}}",overlay:"> .cycle-overlay",overlayTemplate:"
{{title}}
{{desc}}
",captionModule:"caption"}),e(document).on("cycle-update-view",function(t,i,n,s){"caption"===i.captionModule&&e.each(["caption","overlay"],function(){var e=this,t=n[e+"Template"],o=i.API.getComponent(e);o.length&&t?(o.html(i.API.tmpl(t,n,i,s)),o.show()):o.hide()})}),e(document).on("cycle-destroyed",function(t,i){var n;e.each(["caption","overlay"],function(){var e=this,t=i[e+"Template"];i[e]&&t&&(n=i.API.getComponent("caption"),n.empty())})})}(jQuery),/*! command plugin for Cycle2; version: 20130707 */ +function(e){"use strict";var t=e.fn.cycle;e.fn.cycle=function(i){var n,s,o,c=e.makeArray(arguments);return"number"==e.type(i)?this.cycle("goto",i):"string"==e.type(i)?this.each(function(){var r;return n=i,o=e(this).data("cycle.opts"),void 0===o?(t.log('slideshow must be initialized before sending commands; "'+n+'" ignored'),void 0):(n="goto"==n?"jump":n,s=o.API[n],e.isFunction(s)?(r=e.makeArray(c),r.shift(),s.apply(o.API,r)):(t.log("unknown command: ",n),void 0))}):t.apply(this,arguments)},e.extend(e.fn.cycle,t),e.extend(t.API,{next:function(){var e=this.opts();if(!e.busy||e.manualTrump){var t=e.reverse?-1:1;e.allowWrap===!1&&e.currSlide+t>=e.slideCount||(e.API.advanceSlide(t),e.API.trigger("cycle-next",[e]).log("cycle-next"))}},prev:function(){var e=this.opts();if(!e.busy||e.manualTrump){var t=e.reverse?1:-1;e.allowWrap===!1&&0>e.currSlide+t||(e.API.advanceSlide(t),e.API.trigger("cycle-prev",[e]).log("cycle-prev"))}},destroy:function(){this.stop();var t=this.opts(),i=e.isFunction(e._data)?e._data:e.noop;clearTimeout(t.timeoutId),t.timeoutId=0,t.API.stop(),t.API.trigger("cycle-destroyed",[t]).log("cycle-destroyed"),t.container.removeData(),i(t.container[0],"parsedAttrs",!1),t.retainStylesOnDestroy||(t.container.removeAttr("style"),t.slides.removeAttr("style"),t.slides.removeClass(t.slideActiveClass)),t.slides.each(function(){e(this).removeData(),i(this,"parsedAttrs",!1)})},jump:function(e){var t,i=this.opts();if(!i.busy||i.manualTrump){var n=parseInt(e,10);if(isNaN(n)||0>n||n>=i.slides.length)return i.API.log("goto: invalid slide index: "+n),void 0;if(n==i.currSlide)return i.API.log("goto: skipping, already on slide",n),void 0;i.nextSlide=n,clearTimeout(i.timeoutId),i.timeoutId=0,i.API.log("goto: ",n," (zero-index)"),t=i.currSlider;r++)i=s.slides[r],r==t?n=i:(o.push(i),e(i).data("cycle.opts").slideNum=c,c++);n&&(s.slides=e(o),s.slideCount--,e(n).remove(),t==s.currSlide?s.API.advanceSlide(1):s.currSlide>t?s.currSlide--:s.currSlide++,s.API.trigger("cycle-slide-removed",[s,t,n]).log("cycle-slide-removed"),s.API.updateView())}}),e(document).on("click.cycle","[data-cycle-cmd]",function(t){t.preventDefault();var i=e(this),n=i.data("cycle-cmd"),s=i.data("cycle-context")||".cycle-slideshow";e(s).cycle(n,i.data("cycle-arg"))})}(jQuery),/*! hash plugin for Cycle2; version: 20130905 */ +function(e){"use strict";function t(t,i){var n;return t._hashFence?(t._hashFence=!1,void 0):(n=window.location.hash.substring(1),t.slides.each(function(s){if(e(this).data("cycle-hash")==n){if(i===!0)t.startingSlide=s;else{var o=s>t.currSlide;t.nextSlide=s,t.API.prepareTx(!0,o)}return!1}}),void 0)}e(document).on("cycle-pre-initialize",function(i,n){t(n,!0),n._onHashChange=function(){t(n,!1)},e(window).on("hashchange",n._onHashChange)}),e(document).on("cycle-update-view",function(e,t,i){i.hash&&"#"+i.hash!=window.location.hash&&(t._hashFence=!0,window.location.hash=i.hash)}),e(document).on("cycle-destroyed",function(t,i){i._onHashChange&&e(window).off("hashchange",i._onHashChange)})}(jQuery),/*! loader plugin for Cycle2; version: 20130307 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{loader:!1}),e(document).on("cycle-bootstrap",function(t,i){function n(t,n){function o(t){var o;"wait"==i.loader?(r.push(t),0===a&&(r.sort(c),s.apply(i.API,[r,n]),i.container.removeClass("cycle-loading"))):(o=e(i.slides[i.currSlide]),s.apply(i.API,[t,n]),o.show(),i.container.removeClass("cycle-loading"))}function c(e,t){return e.data("index")-t.data("index")}var r=[];if("string"==e.type(t))t=e.trim(t);else if("array"===e.type(t))for(var l=0;t.length>l;l++)t[l]=e(t[l])[0];t=e(t);var a=t.length;a&&(t.hide().appendTo("body").each(function(t){function c(){0===--l&&(--a,o(d))}var l=0,d=e(this),u=d.is("img")?d:d.find("img");return d.data("index",t),u=u.filter(":not(.cycle-loader-ignore)").filter(':not([src=""])'),u.length?(l=u.length,u.each(function(){this.complete?c():e(this).load(function(){c()}).error(function(){0===--l&&(i.API.log("slide skipped; img not loaded:",this.src),0===--a&&"wait"==i.loader&&s.apply(i.API,[r,n]))})}),void 0):(--a,r.push(d),void 0)}),a&&i.container.addClass("cycle-loading"))}var s;i.loader&&(s=i.API.add,i.API.add=n)})}(jQuery),/*! pager plugin for Cycle2; version: 20130525 */ +function(e){"use strict";function t(t,i,n){var s,o=t.API.getComponent("pager");o.each(function(){var o=e(this);if(i.pagerTemplate){var c=t.API.tmpl(i.pagerTemplate,i,t,n[0]);s=e(c).appendTo(o)}else s=o.children().eq(t.slideCount-1);s.on(t.pagerEvent,function(e){e.preventDefault(),t.API.page(o,e.currentTarget)})})}function i(e,t){var i=this.opts();if(!i.busy||i.manualTrump){var n=e.children().index(t),s=n,o=s>i.currSlide;i.currSlide!=s&&(i.nextSlide=s,i.API.prepareTx(!0,o),i.API.trigger("cycle-pager-activated",[i,e,t]))}}e.extend(e.fn.cycle.defaults,{pager:"> .cycle-pager",pagerActiveClass:"cycle-pager-active",pagerEvent:"click.cycle",pagerTemplate:""}),e(document).on("cycle-bootstrap",function(e,i,n){n.buildPagerLink=t}),e(document).on("cycle-slide-added",function(e,t,n,s){t.pager&&(t.API.buildPagerLink(t,n,s),t.API.page=i)}),e(document).on("cycle-slide-removed",function(t,i,n){if(i.pager){var s=i.API.getComponent("pager");s.each(function(){var t=e(this);e(t.children()[n]).remove()})}}),e(document).on("cycle-update-view",function(t,i){var n;i.pager&&(n=i.API.getComponent("pager"),n.each(function(){e(this).children().removeClass(i.pagerActiveClass).eq(i.currSlide).addClass(i.pagerActiveClass)}))}),e(document).on("cycle-destroyed",function(e,t){var i=t.API.getComponent("pager");i&&(i.children().off(t.pagerEvent),t.pagerTemplate&&i.empty())})}(jQuery),/*! prevnext plugin for Cycle2; version: 20130709 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{next:"> .cycle-next",nextEvent:"click.cycle",disabledClass:"disabled",prev:"> .cycle-prev",prevEvent:"click.cycle",swipe:!1}),e(document).on("cycle-initialized",function(e,t){if(t.API.getComponent("next").on(t.nextEvent,function(e){e.preventDefault(),t.API.next()}),t.API.getComponent("prev").on(t.prevEvent,function(e){e.preventDefault(),t.API.prev()}),t.swipe){var i=t.swipeVert?"swipeUp.cycle":"swipeLeft.cycle swipeleft.cycle",n=t.swipeVert?"swipeDown.cycle":"swipeRight.cycle swiperight.cycle";t.container.on(i,function(){t.API.next()}),t.container.on(n,function(){t.API.prev()})}}),e(document).on("cycle-update-view",function(e,t){if(!t.allowWrap){var i=t.disabledClass,n=t.API.getComponent("next"),s=t.API.getComponent("prev"),o=t._prevBoundry||0,c=void 0!==t._nextBoundry?t._nextBoundry:t.slideCount-1;t.currSlide==c?n.addClass(i).prop("disabled",!0):n.removeClass(i).prop("disabled",!1),t.currSlide===o?s.addClass(i).prop("disabled",!0):s.removeClass(i).prop("disabled",!1)}}),e(document).on("cycle-destroyed",function(e,t){t.API.getComponent("prev").off(t.nextEvent),t.API.getComponent("next").off(t.prevEvent),t.container.off("swipeleft.cycle swiperight.cycle swipeLeft.cycle swipeRight.cycle swipeUp.cycle swipeDown.cycle")})}(jQuery),/*! progressive loader plugin for Cycle2; version: 20130315 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{progressive:!1}),e(document).on("cycle-pre-initialize",function(t,i){if(i.progressive){var n,s,o=i.API,c=o.next,r=o.prev,l=o.prepareTx,a=e.type(i.progressive);if("array"==a)n=i.progressive;else if(e.isFunction(i.progressive))n=i.progressive(i);else if("string"==a){if(s=e(i.progressive),n=e.trim(s.html()),!n)return;if(/^(\[)/.test(n))try{n=e.parseJSON(n)}catch(d){return o.log("error parsing progressive slides",d),void 0}else n=n.split(RegExp(s.data("cycle-split")||"\n")),n[n.length-1]||n.pop()}l&&(o.prepareTx=function(e,t){var s,o;return e||0===n.length?(l.apply(i.API,[e,t]),void 0):(t&&i.currSlide==i.slideCount-1?(o=n[0],n=n.slice(1),i.container.one("cycle-slide-added",function(e,t){setTimeout(function(){t.API.advanceSlide(1)},50)}),i.API.add(o)):t||0!==i.currSlide?l.apply(i.API,[e,t]):(s=n.length-1,o=n[s],n=n.slice(0,s),i.container.one("cycle-slide-added",function(e,t){setTimeout(function(){t.currSlide=1,t.API.advanceSlide(-1)},50)}),i.API.add(o,!0)),void 0)}),c&&(o.next=function(){var e=this.opts();if(n.length&&e.currSlide==e.slideCount-1){var t=n[0];n=n.slice(1),e.container.one("cycle-slide-added",function(e,t){c.apply(t.API),t.container.removeClass("cycle-loading")}),e.container.addClass("cycle-loading"),e.API.add(t)}else c.apply(e.API)}),r&&(o.prev=function(){var e=this.opts();if(n.length&&0===e.currSlide){var t=n.length-1,i=n[t];n=n.slice(0,t),e.container.one("cycle-slide-added",function(e,t){t.currSlide=1,t.API.advanceSlide(-1),t.container.removeClass("cycle-loading")}),e.container.addClass("cycle-loading"),e.API.add(i,!0)}else r.apply(e.API)})}})}(jQuery),/*! tmpl plugin for Cycle2; version: 20121227 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{tmplRegex:"{{((.)?.*?)}}"}),e.extend(e.fn.cycle.API,{tmpl:function(t,i){var n=RegExp(i.tmplRegex||e.fn.cycle.defaults.tmplRegex,"g"),s=e.makeArray(arguments);return s.shift(),t.replace(n,function(t,i){var n,o,c,r,l=i.split(".");for(n=0;s.length>n;n++)if(c=s[n]){if(l.length>1)for(r=c,o=0;l.length>o;o++)c=r,r=r[l[o]]||i;else r=c[i];if(e.isFunction(r))return r.apply(c,s);if(void 0!==r&&null!==r&&r!=i)return r}return i})}})}(jQuery); +//@ sourceMappingURL=jquery.cycle2.js.map \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/jquery.cycle2.video.min.js b/app/assets/javascripts/cycle2/jquery.cycle2.video.min.js new file mode 100644 index 0000000..c47c840 --- /dev/null +++ b/app/assets/javascripts/cycle2/jquery.cycle2.video.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20141007 */ +!function(a){"use strict";function b(){try{this.playVideo()}catch(a){}}function c(){try{this.pauseVideo()}catch(a){}}var d='
';a.extend(a.fn.cycle.defaults,{youtubeAllowFullScreen:!0,youtubeAutostart:!1,youtubeAutostop:!0}),a(document).on("cycle-bootstrap",function(e,f){f.youtube&&(f.hideNonActive=!1,f.container.find(f.slides).each(function(b){if(void 0!==a(this).attr("href")){var c,e=a(this),g=e.attr("href"),h=f.youtubeAllowFullScreen?"true":"false";g+=(/\?/.test(g)?"&":"?")+"enablejsapi=1",f.youtubeAutostart&&f.startingSlide===b&&(g+="&autoplay=1"),c=f.API.tmpl(d,{url:g,allowFullScreen:h}),e.replaceWith(c)}}),f.slides=f.slides.replace(/(\b>?a\b)/,"div.cycle-youtube"),f.youtubeAutostart&&f.container.on("cycle-initialized cycle-after",function(c,d){var e="cycle-initialized"==c.type?d.currSlide:d.nextSlide;a(d.slides[e]).find("object,embed").each(b)}),f.youtubeAutostop&&f.container.on("cycle-before",function(b,d){a(d.slides[d.currSlide]).find("object,embed").each(c)}))})}(jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.flip.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.flip.min.js new file mode 100644 index 0000000..5b71b2c --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.flip.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20130909 */ +(function(e){"use strict";function t(t){return{preInit:function(e){e.slides.css(n)},transition:function(i,n,s,o,r){var l=i,c=e(n),a=e(s),d=l.speed/2;t.call(a,-90),a.css({display:"block","background-position":"-90px",opacity:1}),c.css("background-position","0px"),c.animate({backgroundPosition:90},{step:t,duration:d,easing:l.easeOut||l.easing,complete:function(){i.API.updateView(!1,!0),a.animate({backgroundPosition:0},{step:t,duration:d,easing:l.easeIn||l.easing,complete:r})}})}}}function i(t){return function(i){var n=e(this);n.css({"-webkit-transform":"rotate"+t+"("+i+"deg)","-moz-transform":"rotate"+t+"("+i+"deg)","-ms-transform":"rotate"+t+"("+i+"deg)","-o-transform":"rotate"+t+"("+i+"deg)",transform:"rotate"+t+"("+i+"deg)"})}}var n,s=document.createElement("div").style,o=e.fn.cycle.transitions,r=void 0!==s.transform||void 0!==s.MozTransform||void 0!==s.webkitTransform||void 0!==s.oTransform||void 0!==s.msTransform;r&&void 0!==s.msTransform&&(s.msTransform="rotateY(0deg)",s.msTransform||(r=!1)),r?(o.flipHorz=t(i("Y")),o.flipVert=t(i("X")),n={"-webkit-backface-visibility":"hidden","-moz-backface-visibility":"hidden","-o-backface-visibility":"hidden","backface-visibility":"hidden"}):(o.flipHorz=o.scrollHorz,o.flipVert=o.scrollVert||o.scrollHorz)})(jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.ie-fade.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.ie-fade.min.js new file mode 100644 index 0000000..89b50d2 --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.ie-fade.min.js @@ -0,0 +1,2 @@ +/*! Plugin for Cycle2; Copyright (c) 2012 M. Alsup; ver: 20121120 */ +(function(a){function b(a,b,c){if(a&&c.style.filter){b._filter=c.style.filter;try{c.style.removeAttribute("filter")}catch(d){}}else!a&&b._filter&&(c.style.filter=b._filter)}"use strict",a.extend(a.fn.cycle.transitions,{fade:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssBefore=a.extend(g,{opacity:0,display:"block"}),c.animIn={opacity:1},c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}},fadeout:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssBefore=a.extend(g,{opacity:1,display:"block"}),c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}}})})(jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.scrollVert.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.scrollVert.min.js new file mode 100644 index 0000000..c5ebe28 --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.scrollVert.min.js @@ -0,0 +1,2 @@ +/*! Plugin for Cycle2; Copyright (c) 2012 M. Alsup; ver: 20121120 */ +(function(a){"use strict",a.fn.cycle.transitions.scrollVert={before:function(a,b,c,d){a.API.stackSlides(a,b,c,d);var e=a.container.css("overflow","hidden").height();a.cssBefore={top:d?-e:e,left:0,opacity:1,display:"block"},a.animIn={top:0},a.animOut={top:d?e:-e}}}})(jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.tile.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.tile.min.js new file mode 100644 index 0000000..f64379f --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.tile.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20130721 */ +(function(e){"use strict";e.fn.cycle.transitions.tileSlide=e.fn.cycle.transitions.tileBlind={before:function(t,i,n,s){t.API.stackSlides(i,n,s),e(i).show(),t.container.css("overflow","hidden"),t.tileDelay=t.tileDelay||"tileSlide"==t.fx?100:125,t.tileCount=t.tileCount||7,t.tileVertical=t.tileVertical!==!1,t.container.data("cycleTileInitialized")||(t.container.on("cycle-destroyed",e.proxy(this.onDestroy,t.API)),t.container.data("cycleTileInitialized",!0))},transition:function(t,i,n,s,o){function r(e){p.eq(e).animate(I,{duration:t.speed,easing:t.easing,complete:function(){(s?v-1===e:0===e)&&t._tileAniCallback()}}),setTimeout(function(){(s?v-1!==e:0!==e)&&r(s?e+1:e-1)},t.tileDelay)}t.slides.not(i).not(n).hide();var c,l,a,d,u,p=e(),f=e(i),y=e(n),v=t.tileCount,h=t.tileVertical,g=t.container.height(),m=t.container.width();h?(l=Math.floor(m/v),d=m-l*(v-1),a=u=g):(l=d=m,a=Math.floor(g/v),u=g-a*(v-1)),t.container.find(".cycle-tiles-container").remove();var I,A={left:0,top:0,overflow:"hidden",position:"absolute",margin:0,padding:0};I=h?"tileSlide"==t.fx?{top:g}:{width:0}:"tileSlide"==t.fx?{left:m}:{height:0};var S=e('
');S.css({zIndex:f.css("z-index"),overflow:"visible",position:"absolute",top:0,left:0,direction:"ltr"}),S.insertBefore(n);for(var x=0;v>x;x++)c=e("
").css(A).css({width:v-1===x?d:l,height:v-1===x?u:a,marginLeft:h?x*l:0,marginTop:h?0:x*a}).append(f.clone().css({position:"relative",maxWidth:"none",width:f.width(),margin:0,padding:0,marginLeft:h?-(x*l):0,marginTop:h?0:-(x*a)})),p=p.add(c);S.append(p),f.hide(),y.show().css("opacity",1),r(s?0:v-1),t._tileAniCallback=function(){y.show(),f.hide(),S.remove(),o()}},stopTransition:function(e){e.container.find("*").stop(!0,!0),e._tileAniCallback&&e._tileAniCallback()},onDestroy:function(){var e=this.opts();e.container.find(".cycle-tiles-container").remove()}}})(jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/video_pro/jplayer.playlist.js b/app/assets/javascripts/video_pro/jplayer.playlist.js new file mode 100644 index 0000000..725caf0 --- /dev/null +++ b/app/assets/javascripts/video_pro/jplayer.playlist.js @@ -0,0 +1,496 @@ +/* + * Playlist Object for the jPlayer Plugin + * http://www.jplayer.org + * + * Copyright (c) 2009 - 2014 Happyworm Ltd + * Licensed under the MIT license. + * http://www.opensource.org/licenses/MIT + * + * Author: Mark J Panaghiston + * Version: 2.4.1 + * Date: 19th November 2014 + * + * Requires: + * - jQuery 1.7.0+ + * - jPlayer 2.8.2+ + */ + +/*global jPlayerPlaylist:true */ + +(function($, undefined) { + + jPlayerPlaylist = function(cssSelector, playlist, options) { + var self = this; + + this.current = 0; + this.loop = false; // Flag used with the jPlayer repeat event + this.shuffled = false; + this.removing = false; // Flag is true during remove animation, disabling the remove() method until complete. + + this.cssSelector = $.extend({}, this._cssSelector, cssSelector); // Object: Containing the css selectors for jPlayer and its cssSelectorAncestor + this.options = $.extend(true, { + keyBindings: { + next: { + key: 221, // ] + fn: function() { + self.next(); + } + }, + previous: { + key: 219, // [ + fn: function() { + self.previous(); + } + }, + shuffle: { + key: 83, // s + fn: function() { + self.shuffle(); + } + } + }, + stateClass: { + shuffled: "jp-state-shuffled" + } + }, this._options, options); // Object: The jPlayer constructor options for this playlist and the playlist options + + this.playlist = []; // Array of Objects: The current playlist displayed (Un-shuffled or Shuffled) + this.original = []; // Array of Objects: The original playlist + + this._initPlaylist(playlist); // Copies playlist to this.original. Then mirrors this.original to this.playlist. Creating two arrays, where the element pointers match. (Enables pointer comparison.) + + // Setup the css selectors for the extra interface items used by the playlist. + this.cssSelector.details = this.cssSelector.cssSelectorAncestor + " .jp-details"; // Note that jPlayer controls the text in the title element. + this.cssSelector.playlist = this.cssSelector.cssSelectorAncestor + " .jp-playlist"; + this.cssSelector.next = this.cssSelector.cssSelectorAncestor + " .jp-next"; + this.cssSelector.previous = this.cssSelector.cssSelectorAncestor + " .jp-previous"; + this.cssSelector.shuffle = this.cssSelector.cssSelectorAncestor + " .jp-shuffle"; + this.cssSelector.shuffleOff = this.cssSelector.cssSelectorAncestor + " .jp-shuffle-off"; + + // Override the cssSelectorAncestor given in options + this.options.cssSelectorAncestor = this.cssSelector.cssSelectorAncestor; + + // Override the default repeat event handler + this.options.repeat = function(event) { + self.loop = event.jPlayer.options.loop; + }; + + // Create a ready event handler to initialize the playlist + $(this.cssSelector.jPlayer).bind($.jPlayer.event.ready, function() { + self._init(); + }); + + // Create an ended event handler to move to the next item + $(this.cssSelector.jPlayer).bind($.jPlayer.event.ended, function() { + self.next(); + }); + + // Create a play event handler to pause other instances + $(this.cssSelector.jPlayer).bind($.jPlayer.event.play, function() { + $(this).jPlayer("pauseOthers"); + }); + + // Create a resize event handler to show the title in full screen mode. + $(this.cssSelector.jPlayer).bind($.jPlayer.event.resize, function(event) { + if(event.jPlayer.options.fullScreen) { + $(self.cssSelector.details).show(); + } else { + $(self.cssSelector.details).hide(); + } + }); + + // Create click handlers for the extra buttons that do playlist functions. + $(this.cssSelector.previous).click(function(e) { + e.preventDefault(); + self.previous(); + self.blur(this); + }); + + $(this.cssSelector.next).click(function(e) { + e.preventDefault(); + self.next(); + self.blur(this); + }); + + $(this.cssSelector.shuffle).click(function(e) { + e.preventDefault(); + if(self.shuffled && $(self.cssSelector.jPlayer).jPlayer("option", "useStateClassSkin")) { + self.shuffle(false); + } else { + self.shuffle(true); + } + self.blur(this); + }); + $(this.cssSelector.shuffleOff).click(function(e) { + e.preventDefault(); + self.shuffle(false); + self.blur(this); + }).hide(); + + // Put the title in its initial display state + if(!this.options.fullScreen) { + $(this.cssSelector.details).hide(); + } + + // Remove the empty
  • from the page HTML. Allows page to be valid HTML, while not interfereing with display animations + $(this.cssSelector.playlist + " ul").empty(); + + // Create .on() handlers for the playlist items along with the free media and remove controls. + this._createItemHandlers(); + + // Instance jPlayer + $(this.cssSelector.jPlayer).jPlayer(this.options); + }; + + jPlayerPlaylist.prototype = { + _cssSelector: { // static object, instanced in constructor + jPlayer: "#jquery_jplayer_1", + cssSelectorAncestor: "#jp_container_1" + }, + _options: { // static object, instanced in constructor + playlistOptions: { + autoPlay: false, + loopOnPrevious: false, + shuffleOnLoop: true, + enableRemoveControls: false, + displayTime: 'slow', + addTime: 'fast', + removeTime: 'fast', + shuffleTime: 'slow', + itemClass: "jp-playlist-item", + freeGroupClass: "jp-free-media", + freeItemClass: "jp-playlist-item-free", + removeItemClass: "jp-playlist-item-remove" + } + }, + option: function(option, value) { // For changing playlist options only + if(value === undefined) { + return this.options.playlistOptions[option]; + } + + this.options.playlistOptions[option] = value; + + switch(option) { + case "enableRemoveControls": + this._updateControls(); + break; + case "itemClass": + case "freeGroupClass": + case "freeItemClass": + case "removeItemClass": + this._refresh(true); // Instant + this._createItemHandlers(); + break; + } + return this; + }, + _init: function() { + var self = this; + this._refresh(function() { + if(self.options.playlistOptions.autoPlay) { + self.play(self.current); + } else { + self.select(self.current); + } + }); + }, + _initPlaylist: function(playlist) { + this.current = 0; + this.shuffled = false; + this.removing = false; + this.original = $.extend(true, [], playlist); // Copy the Array of Objects + this._originalPlaylist(); + }, + _originalPlaylist: function() { + var self = this; + this.playlist = []; + // Make both arrays point to the same object elements. Gives us 2 different arrays, each pointing to the same actual object. ie., Not copies of the object. + $.each(this.original, function(i) { + self.playlist[i] = self.original[i]; + }); + }, + _refresh: function(instant) { + /* instant: Can be undefined, true or a function. + * undefined -> use animation timings + * true -> no animation + * function -> use animation timings and excute function at half way point. + */ + var self = this; + + if(instant && !$.isFunction(instant)) { + $(this.cssSelector.playlist + " ul").empty(); + $.each(this.playlist, function(i) { + $(self.cssSelector.playlist + " ul").append(self._createListItem(self.playlist[i])); + }); + this._updateControls(); + } else { + var displayTime = $(this.cssSelector.playlist + " ul").children().length ? this.options.playlistOptions.displayTime : 0; + + $(this.cssSelector.playlist + " ul").slideUp(displayTime, function() { + var $this = $(this); + $(this).empty(); + + $.each(self.playlist, function(i) { + $this.append(self._createListItem(self.playlist[i])); + }); + self._updateControls(); + if($.isFunction(instant)) { + instant(); + } + if(self.playlist.length) { + $(this).slideDown(self.options.playlistOptions.displayTime); + } else { + $(this).show(); + } + }); + } + }, + _createListItem: function(media) { + var self = this; + + // Wrap the
  • contents in a
    + var listItem = "
  • "; + + // Create remove control + listItem += "×"; + + // Create links to free media + if(media.free) { + var first = true; + listItem += "("; + $.each(media, function(property,value) { + if($.jPlayer.prototype.format[property]) { // Check property is a media format. + if(first) { + first = false; + } else { + listItem += " | "; + } + listItem += "" + property + ""; + } + }); + listItem += ")"; + } + + // The title is given next in the HTML otherwise the float:right on the free media corrupts in IE6/7 + listItem += "" + media.title + (media.artist ? " " : "") + ""; + listItem += "
  • "; + + return listItem; + }, + _createItemHandlers: function() { + var self = this; + // Create live handlers for the playlist items + $(this.cssSelector.playlist).off("click", "a." + this.options.playlistOptions.itemClass).on("click", "a." + this.options.playlistOptions.itemClass, function(e) { + e.preventDefault(); + var index = $(this).parent().parent().index(); + if(self.current !== index) { + self.play(index); + } else { + $(self.cssSelector.jPlayer).jPlayer("play"); + } + self.blur(this); + }); + + // Create live handlers that disable free media links to force access via right click + $(this.cssSelector.playlist).off("click", "a." + this.options.playlistOptions.freeItemClass).on("click", "a." + this.options.playlistOptions.freeItemClass, function(e) { + e.preventDefault(); + $(this).parent().parent().find("." + self.options.playlistOptions.itemClass).click(); + self.blur(this); + }); + + // Create live handlers for the remove controls + $(this.cssSelector.playlist).off("click", "a." + this.options.playlistOptions.removeItemClass).on("click", "a." + this.options.playlistOptions.removeItemClass, function(e) { + e.preventDefault(); + var index = $(this).parent().parent().index(); + self.remove(index); + self.blur(this); + }); + }, + _updateControls: function() { + if(this.options.playlistOptions.enableRemoveControls) { + $(this.cssSelector.playlist + " ." + this.options.playlistOptions.removeItemClass).show(); + } else { + $(this.cssSelector.playlist + " ." + this.options.playlistOptions.removeItemClass).hide(); + } + + if(this.shuffled) { + $(this.cssSelector.jPlayer).jPlayer("addStateClass", "shuffled"); + } else { + $(this.cssSelector.jPlayer).jPlayer("removeStateClass", "shuffled"); + } + if($(this.cssSelector.shuffle).length && $(this.cssSelector.shuffleOff).length) { + if(this.shuffled) { + $(this.cssSelector.shuffleOff).show(); + $(this.cssSelector.shuffle).hide(); + } else { + $(this.cssSelector.shuffleOff).hide(); + $(this.cssSelector.shuffle).show(); + } + } + }, + _highlight: function(index) { + if(this.playlist.length && index !== undefined) { + $(this.cssSelector.playlist + " .jp-playlist-current").removeClass("jp-playlist-current"); + $(this.cssSelector.playlist + " li:nth-child(" + (index + 1) + ")").addClass("jp-playlist-current").find(".jp-playlist-item").addClass("jp-playlist-current"); + // $(this.cssSelector.details + " li").html("" + (this.playlist[index].artist ? " " : "")); + } + }, + setPlaylist: function(playlist) { + this._initPlaylist(playlist); + this._init(); + }, + add: function(media, playNow) { + $(this.cssSelector.playlist + " ul").append(this._createListItem(media)).find("li:last-child").hide().slideDown(this.options.playlistOptions.addTime); + this._updateControls(); + this.original.push(media); + this.playlist.push(media); // Both array elements share the same object pointer. Comforms with _initPlaylist(p) system. + + if(playNow) { + this.play(this.playlist.length - 1); + } else { + if(this.original.length === 1) { + this.select(0); + } + } + }, + remove: function(index) { + var self = this; + + if(index === undefined) { + this._initPlaylist([]); + this._refresh(function() { + $(self.cssSelector.jPlayer).jPlayer("clearMedia"); + }); + return true; + } else { + + if(this.removing) { + return false; + } else { + index = (index < 0) ? self.original.length + index : index; // Negative index relates to end of array. + if(0 <= index && index < this.playlist.length) { + this.removing = true; + + $(this.cssSelector.playlist + " li:nth-child(" + (index + 1) + ")").slideUp(this.options.playlistOptions.removeTime, function() { + $(this).remove(); + + if(self.shuffled) { + var item = self.playlist[index]; + $.each(self.original, function(i) { + if(self.original[i] === item) { + self.original.splice(i, 1); + return false; // Exit $.each + } + }); + self.playlist.splice(index, 1); + } else { + self.original.splice(index, 1); + self.playlist.splice(index, 1); + } + + if(self.original.length) { + if(index === self.current) { + self.current = (index < self.original.length) ? self.current : self.original.length - 1; // To cope when last element being selected when it was removed + self.select(self.current); + } else if(index < self.current) { + self.current--; + } + } else { + $(self.cssSelector.jPlayer).jPlayer("clearMedia"); + self.current = 0; + self.shuffled = false; + self._updateControls(); + } + + self.removing = false; + }); + } + return true; + } + } + }, + select: function(index) { + index = (index < 0) ? this.original.length + index : index; // Negative index relates to end of array. + if(0 <= index && index < this.playlist.length) { + this.current = index; + this._highlight(index); + $(this.cssSelector.jPlayer).jPlayer("setMedia", this.playlist[this.current]); + } else { + this.current = 0; + } + }, + play: function(index) { + index = (index < 0) ? this.original.length + index : index; // Negative index relates to end of array. + if(0 <= index && index < this.playlist.length) { + if(this.playlist.length) { + this.select(index); + $(this.cssSelector.jPlayer).jPlayer("play"); + } + } else if(index === undefined) { + $(this.cssSelector.jPlayer).jPlayer("play"); + } + }, + pause: function() { + $(this.cssSelector.jPlayer).jPlayer("pause"); + }, + next: function() { + var index = (this.current + 1 < this.playlist.length) ? this.current + 1 : 0; + + if(this.loop) { + // See if we need to shuffle before looping to start, and only shuffle if more than 1 item. + if(index === 0 && this.shuffled && this.options.playlistOptions.shuffleOnLoop && this.playlist.length > 1) { + this.shuffle(true, true); // playNow + } else { + this.play(index); + } + } else { + // The index will be zero if it just looped round + if(index > 0) { + this.play(index); + } + } + }, + previous: function() { + var index = (this.current - 1 >= 0) ? this.current - 1 : this.playlist.length - 1; + + if(this.loop && this.options.playlistOptions.loopOnPrevious || index < this.playlist.length - 1) { + this.play(index); + } + }, + shuffle: function(shuffled, playNow) { + var self = this; + + if(shuffled === undefined) { + shuffled = !this.shuffled; + } + + if(shuffled || shuffled !== this.shuffled) { + + $(this.cssSelector.playlist + " ul").slideUp(this.options.playlistOptions.shuffleTime, function() { + self.shuffled = shuffled; + if(shuffled) { + self.playlist.sort(function() { + return 0.5 - Math.random(); + }); + } else { + self._originalPlaylist(); + } + self._refresh(true); // Instant + + if(playNow || !$(self.cssSelector.jPlayer).data("jPlayer").status.paused) { + self.play(0); + } else { + self.select(0); + } + + $(this).slideDown(self.options.playlistOptions.shuffleTime); + }); + } + }, + blur: function(that) { + if($(this.cssSelector.jPlayer).jPlayer("option", "autoBlur")) { + $(that).blur(); + } + } + }; +})(jQuery); diff --git a/app/assets/javascripts/video_pro/jplayer.playlist.min.js b/app/assets/javascripts/video_pro/jplayer.playlist.min.js new file mode 100644 index 0000000..6a0e866 --- /dev/null +++ b/app/assets/javascripts/video_pro/jplayer.playlist.min.js @@ -0,0 +1,2 @@ +/*! jPlayerPlaylist for jPlayer 2.9.2 ~ (c) 2009-2014 Happyworm Ltd ~ MIT License */ +!function(a,b){jPlayerPlaylist=function(b,c,d){var e=this;this.current=0,this.loop=!1,this.shuffled=!1,this.removing=!1,this.cssSelector=a.extend({},this._cssSelector,b),this.options=a.extend(!0,{keyBindings:{next:{key:221,fn:function(){e.next()}},previous:{key:219,fn:function(){e.previous()}},shuffle:{key:83,fn:function(){e.shuffle()}}},stateClass:{shuffled:"jp-state-shuffled"}},this._options,d),this.playlist=[],this.original=[],this._initPlaylist(c),this.cssSelector.details=this.cssSelector.cssSelectorAncestor+" .jp-details",this.cssSelector.playlist=this.cssSelector.cssSelectorAncestor+" .jp-playlist",this.cssSelector.next=this.cssSelector.cssSelectorAncestor+" .jp-next",this.cssSelector.previous=this.cssSelector.cssSelectorAncestor+" .jp-previous",this.cssSelector.shuffle=this.cssSelector.cssSelectorAncestor+" .jp-shuffle",this.cssSelector.shuffleOff=this.cssSelector.cssSelectorAncestor+" .jp-shuffle-off",this.options.cssSelectorAncestor=this.cssSelector.cssSelectorAncestor,this.options.repeat=function(a){e.loop=a.jPlayer.options.loop},a(this.cssSelector.jPlayer).bind(a.jPlayer.event.ready,function(){e._init()}),a(this.cssSelector.jPlayer).bind(a.jPlayer.event.ended,function(){e.next()}),a(this.cssSelector.jPlayer).bind(a.jPlayer.event.play,function(){a(this).jPlayer("pauseOthers")}),a(this.cssSelector.jPlayer).bind(a.jPlayer.event.resize,function(b){b.jPlayer.options.fullScreen?a(e.cssSelector.details).show():a(e.cssSelector.details).hide()}),a(this.cssSelector.previous).click(function(a){a.preventDefault(),e.previous(),e.blur(this)}),a(this.cssSelector.next).click(function(a){a.preventDefault(),e.next(),e.blur(this)}),a(this.cssSelector.shuffle).click(function(b){b.preventDefault(),e.shuffle(e.shuffled&&a(e.cssSelector.jPlayer).jPlayer("option","useStateClassSkin")?!1:!0),e.blur(this)}),a(this.cssSelector.shuffleOff).click(function(a){a.preventDefault(),e.shuffle(!1),e.blur(this)}).hide(),this.options.fullScreen||a(this.cssSelector.details).hide(),a(this.cssSelector.playlist+" ul").empty(),this._createItemHandlers(),a(this.cssSelector.jPlayer).jPlayer(this.options)},jPlayerPlaylist.prototype={_cssSelector:{jPlayer:"#jquery_jplayer_1",cssSelectorAncestor:"#jp_container_1"},_options:{playlistOptions:{autoPlay:!1,loopOnPrevious:!1,shuffleOnLoop:!0,enableRemoveControls:!1,displayTime:"slow",addTime:"fast",removeTime:"fast",shuffleTime:"slow",itemClass:"jp-playlist-item",freeGroupClass:"jp-free-media",freeItemClass:"jp-playlist-item-free",removeItemClass:"jp-playlist-item-remove"}},option:function(a,c){if(c===b)return this.options.playlistOptions[a];switch(this.options.playlistOptions[a]=c,a){case"enableRemoveControls":this._updateControls();break;case"itemClass":case"freeGroupClass":case"freeItemClass":case"removeItemClass":this._refresh(!0),this._createItemHandlers()}return this},_init:function(){var a=this;this._refresh(function(){a.options.playlistOptions.autoPlay?a.play(a.current):a.select(a.current)})},_initPlaylist:function(b){this.current=0,this.shuffled=!1,this.removing=!1,this.original=a.extend(!0,[],b),this._originalPlaylist()},_originalPlaylist:function(){var b=this;this.playlist=[],a.each(this.original,function(a){b.playlist[a]=b.original[a]})},_refresh:function(b){var c=this;if(b&&!a.isFunction(b))a(this.cssSelector.playlist+" ul").empty(),a.each(this.playlist,function(b){a(c.cssSelector.playlist+" ul").append(c._createListItem(c.playlist[b]))}),this._updateControls();else{var d=a(this.cssSelector.playlist+" ul").children().length?this.options.playlistOptions.displayTime:0;a(this.cssSelector.playlist+" ul").slideUp(d,function(){var d=a(this);a(this).empty(),a.each(c.playlist,function(a){d.append(c._createListItem(c.playlist[a]))}),c._updateControls(),a.isFunction(b)&&b(),c.playlist.length?a(this).slideDown(c.options.playlistOptions.displayTime):a(this).show()})}},_createListItem:function(b){var c=this,d="
  • ";if(d+="×",b.free){var e=!0;d+="(",a.each(b,function(b,f){a.jPlayer.prototype.format[b]&&(e?e=!1:d+=" | ",d+=""+b+"")}),d+=")"}return d+=""+b.title+(b.artist?" ":"")+"",d+="
  • "},_createItemHandlers:function(){var b=this;a(this.cssSelector.playlist).off("click","a."+this.options.playlistOptions.itemClass).on("click","a."+this.options.playlistOptions.itemClass,function(c){c.preventDefault();var d=a(this).parent().parent().index();b.current!==d?b.play(d):a(b.cssSelector.jPlayer).jPlayer("play"),b.blur(this)}),a(this.cssSelector.playlist).off("click","a."+this.options.playlistOptions.freeItemClass).on("click","a."+this.options.playlistOptions.freeItemClass,function(c){c.preventDefault(),a(this).parent().parent().find("."+b.options.playlistOptions.itemClass).click(),b.blur(this)}),a(this.cssSelector.playlist).off("click","a."+this.options.playlistOptions.removeItemClass).on("click","a."+this.options.playlistOptions.removeItemClass,function(c){c.preventDefault();var d=a(this).parent().parent().index();b.remove(d),b.blur(this)})},_updateControls:function(){this.options.playlistOptions.enableRemoveControls?a(this.cssSelector.playlist+" ."+this.options.playlistOptions.removeItemClass).show():a(this.cssSelector.playlist+" ."+this.options.playlistOptions.removeItemClass).hide(),this.shuffled?a(this.cssSelector.jPlayer).jPlayer("addStateClass","shuffled"):a(this.cssSelector.jPlayer).jPlayer("removeStateClass","shuffled"),a(this.cssSelector.shuffle).length&&a(this.cssSelector.shuffleOff).length&&(this.shuffled?(a(this.cssSelector.shuffleOff).show(),a(this.cssSelector.shuffle).hide()):(a(this.cssSelector.shuffleOff).hide(),a(this.cssSelector.shuffle).show()))},_highlight:function(c){this.playlist.length&&c!==b&&(a(this.cssSelector.playlist+" .jp-playlist-current").removeClass("jp-playlist-current"),a(this.cssSelector.playlist+" li:nth-child("+(c+1)+")").addClass("jp-playlist-current").find(".jp-playlist-item").addClass("jp-playlist-current"))},setPlaylist:function(a){this._initPlaylist(a),this._init()},add:function(b,c){a(this.cssSelector.playlist+" ul").append(this._createListItem(b)).find("li:last-child").hide().slideDown(this.options.playlistOptions.addTime),this._updateControls(),this.original.push(b),this.playlist.push(b),c?this.play(this.playlist.length-1):1===this.original.length&&this.select(0)},remove:function(c){var d=this;return c===b?(this._initPlaylist([]),this._refresh(function(){a(d.cssSelector.jPlayer).jPlayer("clearMedia")}),!0):this.removing?!1:(c=0>c?d.original.length+c:c,c>=0&&cb?this.original.length+b:b,b>=0&&bc?this.original.length+c:c,c>=0&&c1?this.shuffle(!0,!0):this.play(a):a>0&&this.play(a)},previous:function(){var a=this.current-1>=0?this.current-1:this.playlist.length-1;(this.loop&&this.options.playlistOptions.loopOnPrevious||a50,shape:!1,encodeURI:!0,removeOverflowing:!0};n=e.extend(s,n||{}),r.addClass("jqcloud").width(n.width).height(n.height),r.css("position")==="static"&&r.css("position","relative");var o=function(){var s=function(e,t){var n=function(e,t){return Math.abs(2*e.offsetLeft+e.offsetWidth-2*t.offsetLeft-t.offsetWidth)t.weight?-1:0});var u=n.shape==="rectangular"?18:2,a=[],f=n.width/n.height,l=function(o,l){var c=i+"_word_"+o,h="#"+c,p=6.28*Math.random(),d=0,v=0,m=0,g=5,y="",b="",w;l.html=e.extend(l.html,{id:c}),l.html&&l.html["class"]&&(y=l.html["class"],delete l.html["class"]),t[0].weight>t[t.length-1].weight&&(g=Math.round((l.weight-t[t.length-1].weight)/(t[0].weight-t[t.length-1].weight)*9)+1),w=e("").attr(l.html).addClass("w"+g+" "+y),l.link?(typeof l.link=="string"&&(l.link={href:l.link}),n.encodeURI&&(l.link=e.extend(l.link,{href:encodeURI(l.link.href).replace(/'/g,"%27")})),b=e("").attr(l.link).text(l.text)):b=l.text,w.append(b);if(!!l.handlers)for(var E in l.handlers)l.handlers.hasOwnProperty(E)&&typeof l.handlers[E]=="function"&&e(w).bind(E,l.handlers[E]);r.append(w);var S=w.width(),x=w.height(),T=n.center.x-S/2,N=n.center.y-x/2,C=w[0].style;C.position="absolute",C.left=T+"px",C.top=N+"px";while(s(w[0],a)){if(n.shape==="rectangular"){v++,v*u>(1+Math.floor(m/2))*u*(m%4%2===0?1:f)&&(v=0,m++);switch(m%4){case 1:T+=u*f+Math.random()*2;break;case 2:N-=u+Math.random()*2;break;case 3:T-=u*f+Math.random()*2;break;case 0:N+=u+Math.random()*2}}else d+=u,p+=(o%2===0?1:-1)*u,T=n.center.x-S/2+d*Math.cos(p)*f,N=n.center.y+d*Math.sin(p)-x/2;C.left=T+"px",C.top=N+"px"}if(n.removeOverflowing&&(T<0||N<0||T+S>n.width||N+x>n.height)){w.remove();return}a.push(w[0]),e.isFunction(l.afterWordRender)&&l.afterWordRender.call(w)},c=function(i){i=i||0;if(!r.is(":visible")){setTimeout(function(){c(i)},10);return}i' + (config.visible ? "Hide" : "Show") + ' jPlayer Inspector

    ' + + '
    ' + + '
    ' + + '
    ' + + '

    jPlayer events that have occurred over the past 1 second:' + + '
    (Backgrounds: Never occurred Occurred before Occurred Multiple occurrences reset)

    '; + + // MJP: Would use the next 3 lines for ease, but the events are just slapped on the page. + // $.each($.jPlayer.event, function(eventName,eventType) { + // structure += '
    ' + eventName + '
    '; + // }); + + var eventStyle = "float:left;margin:0 5px 5px 0;padding:0 5px;border:1px dotted #000;"; + // MJP: Doing it longhand so order and layout easier to control. + structure += + '
    ' + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + + '
    '; + + // MJP: Would like a check here in case we missed an event. + + // MJP: Check fails, since it is not on the page yet. +/* $.each($.jPlayer.event, function(eventName,eventType) { + if($("#" + config.eventId[eventType])[0] === undefined) { + structure += '
    ' + eventName + '
    '; + } + }); +*/ + structure += + '
    ' + + '

    Update jPlayer Inspector

    ' + + '
    ' + + '
    '; + $(this).html(structure); + + config.windowJq = $("#" + config.windowId); + config.statusJq = $("#" + config.statusId); + config.configJq = $("#" + config.configId); + config.toggleJq = $("#" + config.toggleId); + config.eventResetJq = $("#" + config.eventResetId); + config.updateJq = $("#" + config.updateId); + + $.each($.jPlayer.event, function(eventName,eventType) { + config.eventJq[eventType] = $("#" + config.eventId[eventType]); + config.eventJq[eventType].text(eventName + " (" + config.eventOccurrence[eventType] + ")"); // Sets the text to the event name and (0); + + config.jPlayer.bind(eventType + ".jPlayerInspector", function(e) { + config.eventOccurrence[e.type]++; + if(config.eventOccurrence[e.type] > 1) { + config.eventJq[e.type].css("background-color","#ff9"); + } else { + config.eventJq[e.type].css("background-color","#9f9"); + } + config.eventJq[e.type].text(eventName + " (" + config.eventOccurrence[e.type] + ")"); + // The timer to handle the color + clearTimeout(config.eventTimeout[e.type]); + config.eventTimeout[e.type] = setTimeout(function() { + config.eventJq[e.type].css("background-color","#fff"); + }, 1000); + // The timer to handle the occurences. + setTimeout(function() { + config.eventOccurrence[e.type]--; + config.eventJq[e.type].text(eventName + " (" + config.eventOccurrence[e.type] + ")"); + }, 1000); + if(config.visible) { // Update the status, if inspector open. + $this.jPlayerInspector("updateStatus"); + } + }); + }); + + config.jPlayer.bind($.jPlayer.event.ready + ".jPlayerInspector", function(e) { + $this.jPlayerInspector("updateConfig"); + }); + + config.toggleJq.click(function() { + if(config.visible) { + $(this).text("Show"); + config.windowJq.hide(); + config.statusJq.empty(); + config.configJq.empty(); + } else { + $(this).text("Hide"); + config.windowJq.show(); + config.updateJq.click(); + } + config.visible = !config.visible; + $(this).blur(); + return false; + }); + + config.eventResetJq.click(function() { + $.each($.jPlayer.event, function(eventName,eventType) { + config.eventJq[eventType].css("background-color","#eee"); + }); + $(this).blur(); + return false; + }); + + config.updateJq.click(function() { + $this.jPlayerInspector("updateStatus"); + $this.jPlayerInspector("updateConfig"); + return false; + }); + + if(!config.visible) { + config.windowJq.hide(); + } else { + // config.updateJq.click(); + } + + $.jPlayerInspector.i++; + + return this; + }, + destroy: function() { + $(this).data("jPlayerInspector") && $(this).data("jPlayerInspector").jPlayer.unbind(".jPlayerInspector"); + $(this).empty(); + }, + updateConfig: function() { // This displays information about jPlayer's configuration in inspector + + var jPlayerInfo = "

    This jPlayer instance is running in your browser where:
    " + + for(i = 0; i < $(this).data("jPlayerInspector").jPlayer.data("jPlayer").solutions.length; i++) { + var solution = $(this).data("jPlayerInspector").jPlayer.data("jPlayer").solutions[i]; + jPlayerInfo += " jPlayer's " + solution + " solution is"; + if($(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].used) { + jPlayerInfo += " being used and will support:"; + for(format in $(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].support) { + if($(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].support[format]) { + jPlayerInfo += " " + format; + } + } + jPlayerInfo += "
    "; + } else { + jPlayerInfo += " not required
    "; + } + } + jPlayerInfo += "

    "; + + if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.active) { + if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").flash.active) { + jPlayerInfo += "Problem with jPlayer since both HTML5 and Flash are active."; + } else { + jPlayerInfo += "The HTML5 is active."; + } + } else { + if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").flash.active) { + jPlayerInfo += "The Flash is active."; + } else { + jPlayerInfo += "No solution is currently active. jPlayer needs a setMedia()."; + } + } + jPlayerInfo += "

    "; + + var formatType = $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.formatType; + jPlayerInfo += "

    status.formatType = '" + formatType + "'
    "; + if(formatType) { + jPlayerInfo += "Browser canPlay('" + $.jPlayer.prototype.format[formatType].codec + "')"; + } else { + jPlayerInfo += "

    "; + } + + jPlayerInfo += "

    status.src = '" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.src + "'

    "; + + jPlayerInfo += "

    status.media = {
    "; + for(prop in $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.media) { + jPlayerInfo += " " + prop + ": " + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.media[prop] + "
    "; // Some are strings + } + jPlayerInfo += "};

    " + + jPlayerInfo += "

    "; + jPlayerInfo += "status.videoWidth = '" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.videoWidth + "'"; + jPlayerInfo += " | status.videoHeight = '" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.videoHeight + "'"; + jPlayerInfo += "
    status.width = '" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.width + "'"; + jPlayerInfo += " | status.height = '" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.height + "'"; + jPlayerInfo += "

    "; + + + "

    Raw browser test for HTML5 support. Should equal a function if HTML5 is available.
    "; + if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.audio.available) { + jPlayerInfo += "htmlElement.audio.canPlayType = " + (typeof $(this).data("jPlayerInspector").jPlayer.data("jPlayer").htmlElement.audio.canPlayType) +"
    " + } + if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.video.available) { + jPlayerInfo += "htmlElement.video.canPlayType = " + (typeof $(this).data("jPlayerInspector").jPlayer.data("jPlayer").htmlElement.video.canPlayType) +""; + } + jPlayerInfo += "

    "; + + jPlayerInfo += "

    This instance is using the constructor options:
    " + + "$('#" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").internal.self.id + "').jPlayer({
    " + + + " swfPath: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "swfPath") + "',
    " + + + " solution: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "solution") + "',
    " + + + " supplied: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "supplied") + "',
    " + + + " preload: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "preload") + "',
    " + + + " volume: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "volume") + ",
    " + + + " muted: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "muted") + ",
    " + + + " backgroundColor: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "backgroundColor") + "',
    " + + + " cssSelectorAncestor: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelectorAncestor") + "',
    " + + + " cssSelector: {"; + + var cssSelector = $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector"); + for(prop in cssSelector) { + + // jPlayerInfo += "
      " + prop + ": '" + cssSelector[prop] + "'," // This works too of course, but want to use option method for deep keys. + jPlayerInfo += "
      " + prop + ": '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector." + prop) + "'," + } + + jPlayerInfo = jPlayerInfo.slice(0, -1); // Because the sloppy comma was bugging me. + + jPlayerInfo += "
     },
    " + + + " errorAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "errorAlerts") + ",
    " + + + " warningAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "warningAlerts") + "
    " + + + "});

    "; + $(this).data("jPlayerInspector").configJq.html(jPlayerInfo); + return this; + }, + updateStatus: function() { // This displays information about jPlayer's status in the inspector + $(this).data("jPlayerInspector").statusJq.html( + "

    jPlayer is " + + ($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.paused ? "paused" : "playing") + + " at time: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentTime*10)/10 + "s." + + " (d: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.duration*10)/10 + "s" + + ", sp: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.seekPercent) + "%" + + ", cpr: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentRelative) + "%" + + ", cpa: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentAbsolute) + "%)

    " + ); + return this; + } + }; + $.fn.jPlayerInspector = function( method ) { + // Method calling logic + if ( methods[method] ) { + return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 )); + } else if ( typeof method === 'object' || ! method ) { + return methods.init.apply( this, arguments ); + } else { + $.error( 'Method ' + method + ' does not exist on jQuery.jPlayerInspector' ); + } + }; +})(jQuery); diff --git a/app/assets/javascripts/video_pro/jquery.jplayer.inspector.min.js b/app/assets/javascripts/video_pro/jquery.jplayer.inspector.min.js new file mode 100644 index 0000000..69925c8 --- /dev/null +++ b/app/assets/javascripts/video_pro/jquery.jplayer.inspector.min.js @@ -0,0 +1,2 @@ +/*! jPlayerInspector for jPlayer 2.9.2 ~ (c) 2009-2014 Happyworm Ltd ~ MIT License */ +!function(a,b){a.jPlayerInspector={},a.jPlayerInspector.i=0,a.jPlayerInspector.defaults={jPlayer:b,idPrefix:"jplayer_inspector_",visible:!1};var c={init:function(b){var c=a(this),d=a.extend({},a.jPlayerInspector.defaults,b);a(this).data("jPlayerInspector",d),d.id=a(this).attr("id"),d.jPlayerId=d.jPlayer.attr("id"),d.windowId=d.idPrefix+"window_"+a.jPlayerInspector.i,d.statusId=d.idPrefix+"status_"+a.jPlayerInspector.i,d.configId=d.idPrefix+"config_"+a.jPlayerInspector.i,d.toggleId=d.idPrefix+"toggle_"+a.jPlayerInspector.i,d.eventResetId=d.idPrefix+"event_reset_"+a.jPlayerInspector.i,d.updateId=d.idPrefix+"update_"+a.jPlayerInspector.i,d.eventWindowId=d.idPrefix+"event_window_"+a.jPlayerInspector.i,d.eventId={},d.eventJq={},d.eventTimeout={},d.eventOccurrence={},a.each(a.jPlayer.event,function(b,c){d.eventId[c]=d.idPrefix+"event_"+b+"_"+a.jPlayerInspector.i,d.eventOccurrence[c]=0});var e='

    '+(d.visible?"Hide":"Show")+' jPlayer Inspector

    jPlayer events that have occurred over the past 1 second:
    (Backgrounds: Never occurred Occurred before Occurred Multiple occurrences reset)

    ',f="float:left;margin:0 5px 5px 0;padding:0 5px;border:1px dotted #000;";return e+='
    ',e+='

    Update jPlayer Inspector

    ',a(this).html(e),d.windowJq=a("#"+d.windowId),d.statusJq=a("#"+d.statusId),d.configJq=a("#"+d.configId),d.toggleJq=a("#"+d.toggleId),d.eventResetJq=a("#"+d.eventResetId),d.updateJq=a("#"+d.updateId),a.each(a.jPlayer.event,function(b,e){d.eventJq[e]=a("#"+d.eventId[e]),d.eventJq[e].text(b+" ("+d.eventOccurrence[e]+")"),d.jPlayer.bind(e+".jPlayerInspector",function(a){d.eventOccurrence[a.type]++,d.eventOccurrence[a.type]>1?d.eventJq[a.type].css("background-color","#ff9"):d.eventJq[a.type].css("background-color","#9f9"),d.eventJq[a.type].text(b+" ("+d.eventOccurrence[a.type]+")"),clearTimeout(d.eventTimeout[a.type]),d.eventTimeout[a.type]=setTimeout(function(){d.eventJq[a.type].css("background-color","#fff")},1e3),setTimeout(function(){d.eventOccurrence[a.type]--,d.eventJq[a.type].text(b+" ("+d.eventOccurrence[a.type]+")")},1e3),d.visible&&c.jPlayerInspector("updateStatus")})}),d.jPlayer.bind(a.jPlayer.event.ready+".jPlayerInspector",function(){c.jPlayerInspector("updateConfig")}),d.toggleJq.click(function(){return d.visible?(a(this).text("Show"),d.windowJq.hide(),d.statusJq.empty(),d.configJq.empty()):(a(this).text("Hide"),d.windowJq.show(),d.updateJq.click()),d.visible=!d.visible,a(this).blur(),!1}),d.eventResetJq.click(function(){return a.each(a.jPlayer.event,function(a,b){d.eventJq[b].css("background-color","#eee")}),a(this).blur(),!1}),d.updateJq.click(function(){return c.jPlayerInspector("updateStatus"),c.jPlayerInspector("updateConfig"),!1}),d.visible||d.windowJq.hide(),a.jPlayerInspector.i++,this},destroy:function(){a(this).data("jPlayerInspector")&&a(this).data("jPlayerInspector").jPlayer.unbind(".jPlayerInspector"),a(this).empty()},updateConfig:function(){var b="

    This jPlayer instance is running in your browser where:
    ";for(i=0;i"+c+" solution is",a(this).data("jPlayerInspector").jPlayer.data("jPlayer")[c].used){b+=" being used and will support:";for(format in a(this).data("jPlayerInspector").jPlayer.data("jPlayer")[c].support)a(this).data("jPlayerInspector").jPlayer.data("jPlayer")[c].support[format]&&(b+=" "+format);b+="
    "}else b+=" not required
    "}b+="

    ",b+=a(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.active?a(this).data("jPlayerInspector").jPlayer.data("jPlayer").flash.active?"Problem with jPlayer since both HTML5 and Flash are active.":"The HTML5 is active.":a(this).data("jPlayerInspector").jPlayer.data("jPlayer").flash.active?"The Flash is active.":"No solution is currently active. jPlayer needs a setMedia().",b+="

    ";var d=a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.formatType;b+="

    status.formatType = '"+d+"'
    ",b+=d?"Browser canPlay('"+a.jPlayer.prototype.format[d].codec+"')":"

    ",b+="

    status.src = '"+a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.src+"'

    ",b+="

    status.media = {
    ";for(prop in a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.media)b+=" "+prop+": "+a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.media[prop]+"
    ";b+="};

    ",b+="

    ",b+="status.videoWidth = '"+a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.videoWidth+"'",b+=" | status.videoHeight = '"+a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.videoHeight+"'",b+="
    status.width = '"+a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.width+"'",b+=" | status.height = '"+a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.height+"'",b+="

    ",a(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.audio.available&&(b+="htmlElement.audio.canPlayType = "+typeof a(this).data("jPlayerInspector").jPlayer.data("jPlayer").htmlElement.audio.canPlayType+"
    "),a(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.video.available&&(b+="htmlElement.video.canPlayType = "+typeof a(this).data("jPlayerInspector").jPlayer.data("jPlayer").htmlElement.video.canPlayType+""),b+="

    ",b+="

    This instance is using the constructor options:
    $('#"+a(this).data("jPlayerInspector").jPlayer.data("jPlayer").internal.self.id+"').jPlayer({
     swfPath: '"+a(this).data("jPlayerInspector").jPlayer.jPlayer("option","swfPath")+"',
     solution: '"+a(this).data("jPlayerInspector").jPlayer.jPlayer("option","solution")+"',
     supplied: '"+a(this).data("jPlayerInspector").jPlayer.jPlayer("option","supplied")+"',
     preload: '"+a(this).data("jPlayerInspector").jPlayer.jPlayer("option","preload")+"',
     volume: "+a(this).data("jPlayerInspector").jPlayer.jPlayer("option","volume")+",
     muted: "+a(this).data("jPlayerInspector").jPlayer.jPlayer("option","muted")+",
     backgroundColor: '"+a(this).data("jPlayerInspector").jPlayer.jPlayer("option","backgroundColor")+"',
     cssSelectorAncestor: '"+a(this).data("jPlayerInspector").jPlayer.jPlayer("option","cssSelectorAncestor")+"',
     cssSelector: {";var e=a(this).data("jPlayerInspector").jPlayer.jPlayer("option","cssSelector");for(prop in e)b+="
      "+prop+": '"+a(this).data("jPlayerInspector").jPlayer.jPlayer("option","cssSelector."+prop)+"',";return b=b.slice(0,-1),b+="
     },
     errorAlerts: "+a(this).data("jPlayerInspector").jPlayer.jPlayer("option","errorAlerts")+",
     warningAlerts: "+a(this).data("jPlayerInspector").jPlayer.jPlayer("option","warningAlerts")+"
    });

    ",a(this).data("jPlayerInspector").configJq.html(b),this},updateStatus:function(){return a(this).data("jPlayerInspector").statusJq.html("

    jPlayer is "+(a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.paused?"paused":"playing")+" at time: "+Math.floor(10*a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentTime)/10+"s. (d: "+Math.floor(10*a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.duration)/10+"s, sp: "+Math.floor(a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.seekPercent)+"%, cpr: "+Math.floor(a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentRelative)+"%, cpa: "+Math.floor(a(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentAbsolute)+"%)

    "),this}};a.fn.jPlayerInspector=function(b){return c[b]?c[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?void a.error("Method "+b+" does not exist on jQuery.jPlayerInspector"):c.init.apply(this,arguments)}}(jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/video_pro/jquery.jplayer.js b/app/assets/javascripts/video_pro/jquery.jplayer.js new file mode 100644 index 0000000..84aa54c --- /dev/null +++ b/app/assets/javascripts/video_pro/jquery.jplayer.js @@ -0,0 +1,3506 @@ +/* + * jPlayer Plugin for jQuery JavaScript Library + * http://www.jplayer.org + * + * Copyright (c) 2009 - 2014 Happyworm Ltd + * Licensed under the MIT license. + * http://opensource.org/licenses/MIT + * + * Author: Mark J Panaghiston + * Version: 2.9.2 + * Date: 14th December 2014 + */ + +/* Support for Zepto 1.0 compiled with optional data module. + * For AMD or NODE/CommonJS support, you will need to manually switch the related 2 lines in the code below. + * Search terms: "jQuery Switch" and "Zepto Switch" + */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); // jQuery Switch + // define(['zepto'], factory); // Zepto Switch + } else if (typeof exports === 'object') { + // Node/CommonJS + factory(require('jquery')); // jQuery Switch + //factory(require('zepto')); // Zepto Switch + } else { + // Browser globals + if(root.jQuery) { // Use jQuery if available + factory(root.jQuery); + } else { // Otherwise, use Zepto + factory(root.Zepto); + } + } +}(this, function ($, undefined) { + + // Adapted from jquery.ui.widget.js (1.8.7): $.widget.bridge - Tweaked $.data(this,XYZ) to $(this).data(XYZ) for Zepto + $.fn.jPlayer = function( options ) { + var name = "jPlayer"; + var isMethodCall = typeof options === "string", + args = Array.prototype.slice.call( arguments, 1 ), + returnValue = this; + + // allow multiple hashes to be passed on init + options = !isMethodCall && args.length ? + $.extend.apply( null, [ true, options ].concat(args) ) : + options; + + // prevent calls to internal methods + if ( isMethodCall && options.charAt( 0 ) === "_" ) { + return returnValue; + } + + if ( isMethodCall ) { + this.each(function() { + var instance = $(this).data( name ), + methodValue = instance && $.isFunction( instance[options] ) ? + instance[ options ].apply( instance, args ) : + instance; + if ( methodValue !== instance && methodValue !== undefined ) { + returnValue = methodValue; + return false; + } + }); + } else { + this.each(function() { + var instance = $(this).data( name ); + if ( instance ) { + // instance.option( options || {} )._init(); // Orig jquery.ui.widget.js code: Not recommend for jPlayer. ie., Applying new options to an existing instance (via the jPlayer constructor) and performing the _init(). The _init() is what concerns me. It would leave a lot of event handlers acting on jPlayer instance and the interface. + instance.option( options || {} ); // The new constructor only changes the options. Changing options only has basic support atm. + } else { + $(this).data( name, new $.jPlayer( options, this ) ); + } + }); + } + + return returnValue; + }; + + $.jPlayer = function( options, element ) { + // allow instantiation without initializing for simple inheritance + if ( arguments.length ) { + this.element = $(element); + this.options = $.extend(true, {}, + this.options, + options + ); + var self = this; + this.element.bind( "remove.jPlayer", function() { + self.destroy(); + }); + this._init(); + } + }; + // End of: (Adapted from jquery.ui.widget.js (1.8.7)) + + // Zepto is missing one of the animation methods. + if(typeof $.fn.stop !== 'function') { + $.fn.stop = function() {}; + } + + // Emulated HTML5 methods and properties + $.jPlayer.emulateMethods = "load play pause"; + $.jPlayer.emulateStatus = "src readyState networkState currentTime duration paused ended playbackRate"; + $.jPlayer.emulateOptions = "muted volume"; + + // Reserved event names generated by jPlayer that are not part of the HTML5 Media element spec + $.jPlayer.reservedEvent = "ready flashreset resize repeat error warning"; + + // Events generated by jPlayer + $.jPlayer.event = {}; + $.each( + [ + 'ready', + 'setmedia', // Fires when the media is set + 'flashreset', // Similar to the ready event if the Flash solution is set to display:none and then shown again or if it's reloaded for another reason by the browser. For example, using CSS position:fixed on Firefox for the full screen feature. + 'resize', // Occurs when the size changes through a full/restore screen operation or if the size/sizeFull options are changed. + 'repeat', // Occurs when the repeat status changes. Usually through clicks on the repeat button of the interface. + 'click', // Occurs when the user clicks on one of the following: poster image, html video, flash video. + 'error', // Event error code in event.jPlayer.error.type. See $.jPlayer.error + 'warning', // Event warning code in event.jPlayer.warning.type. See $.jPlayer.warning + + // Other events match HTML5 spec. + 'loadstart', + 'progress', + 'suspend', + 'abort', + 'emptied', + 'stalled', + 'play', + 'pause', + 'loadedmetadata', + 'loadeddata', + 'waiting', + 'playing', + 'canplay', + 'canplaythrough', + 'seeking', + 'seeked', + 'timeupdate', + 'ended', + 'ratechange', + 'durationchange', + 'volumechange' + ], + function() { + $.jPlayer.event[ this ] = 'jPlayer_' + this; + } + ); + + $.jPlayer.htmlEvent = [ // These HTML events are bubbled through to the jPlayer event, without any internal action. + "loadstart", + // "progress", // jPlayer uses internally before bubbling. + // "suspend", // jPlayer uses internally before bubbling. + "abort", + // "error", // jPlayer uses internally before bubbling. + "emptied", + "stalled", + // "play", // jPlayer uses internally before bubbling. + // "pause", // jPlayer uses internally before bubbling. + "loadedmetadata", + // "loadeddata", // jPlayer uses internally before bubbling. + // "waiting", // jPlayer uses internally before bubbling. + // "playing", // jPlayer uses internally before bubbling. + "canplay", + "canplaythrough" + // "seeking", // jPlayer uses internally before bubbling. + // "seeked", // jPlayer uses internally before bubbling. + // "timeupdate", // jPlayer uses internally before bubbling. + // "ended", // jPlayer uses internally before bubbling. + // "ratechange" // jPlayer uses internally before bubbling. + // "durationchange" // jPlayer uses internally before bubbling. + // "volumechange" // jPlayer uses internally before bubbling. + ]; + + $.jPlayer.pause = function() { + $.jPlayer.prototype.destroyRemoved(); + $.each($.jPlayer.prototype.instances, function(i, element) { + if(element.data("jPlayer").status.srcSet) { // Check that media is set otherwise would cause error event. + element.jPlayer("pause"); + } + }); + }; + + // Default for jPlayer option.timeFormat + $.jPlayer.timeFormat = { + showHour: false, + showMin: true, + showSec: true, + padHour: false, + padMin: true, + padSec: true, + sepHour: ":", + sepMin: ":", + sepSec: "" + }; + var ConvertTime = function() { + this.init(); + }; + ConvertTime.prototype = { + init: function() { + this.options = { + timeFormat: $.jPlayer.timeFormat + }; + }, + time: function(s) { // function used on jPlayer.prototype._convertTime to enable per instance options. + s = (s && typeof s === 'number') ? s : 0; + + var myTime = new Date(s * 1000), + hour = myTime.getUTCHours(), + min = this.options.timeFormat.showHour ? myTime.getUTCMinutes() : myTime.getUTCMinutes() + hour * 60, + sec = this.options.timeFormat.showMin ? myTime.getUTCSeconds() : myTime.getUTCSeconds() + min * 60, + strHour = (this.options.timeFormat.padHour && hour < 10) ? "0" + hour : hour, + strMin = (this.options.timeFormat.padMin && min < 10) ? "0" + min : min, + strSec = (this.options.timeFormat.padSec && sec < 10) ? "0" + sec : sec, + strTime = ""; + + strTime += this.options.timeFormat.showHour ? strHour + this.options.timeFormat.sepHour : ""; + strTime += this.options.timeFormat.showMin ? strMin + this.options.timeFormat.sepMin : ""; + strTime += this.options.timeFormat.showSec ? strSec + this.options.timeFormat.sepSec : ""; + + return strTime; + } + }; + var myConvertTime = new ConvertTime(); + $.jPlayer.convertTime = function(s) { + return myConvertTime.time(s); + }; + + // Adapting jQuery 1.4.4 code for jQuery.browser. Required since jQuery 1.3.2 does not detect Chrome as webkit. + $.jPlayer.uaBrowser = function( userAgent ) { + var ua = userAgent.toLowerCase(); + + // Useragent RegExp + var rwebkit = /(webkit)[ \/]([\w.]+)/; + var ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/; + var rmsie = /(msie) ([\w.]+)/; + var rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/; + + var match = rwebkit.exec( ua ) || + ropera.exec( ua ) || + rmsie.exec( ua ) || + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || + []; + + return { browser: match[1] || "", version: match[2] || "0" }; + }; + + // Platform sniffer for detecting mobile devices + $.jPlayer.uaPlatform = function( userAgent ) { + var ua = userAgent.toLowerCase(); + + // Useragent RegExp + var rplatform = /(ipad|iphone|ipod|android|blackberry|playbook|windows ce|webos)/; + var rtablet = /(ipad|playbook)/; + var randroid = /(android)/; + var rmobile = /(mobile)/; + + var platform = rplatform.exec( ua ) || []; + var tablet = rtablet.exec( ua ) || + !rmobile.exec( ua ) && randroid.exec( ua ) || + []; + + if(platform[1]) { + platform[1] = platform[1].replace(/\s/g, "_"); // Change whitespace to underscore. Enables dot notation. + } + + return { platform: platform[1] || "", tablet: tablet[1] || "" }; + }; + + $.jPlayer.browser = { + }; + $.jPlayer.platform = { + }; + + var browserMatch = $.jPlayer.uaBrowser(navigator.userAgent); + if ( browserMatch.browser ) { + $.jPlayer.browser[ browserMatch.browser ] = true; + $.jPlayer.browser.version = browserMatch.version; + } + var platformMatch = $.jPlayer.uaPlatform(navigator.userAgent); + if ( platformMatch.platform ) { + $.jPlayer.platform[ platformMatch.platform ] = true; + $.jPlayer.platform.mobile = !platformMatch.tablet; + $.jPlayer.platform.tablet = !!platformMatch.tablet; + } + + // Internet Explorer (IE) Browser Document Mode Sniffer. Based on code at: + // http://msdn.microsoft.com/en-us/library/cc288325%28v=vs.85%29.aspx#GetMode + $.jPlayer.getDocMode = function() { + var docMode; + if ($.jPlayer.browser.msie) { + if (document.documentMode) { // IE8 or later + docMode = document.documentMode; + } else { // IE 5-7 + docMode = 5; // Assume quirks mode unless proven otherwise + if (document.compatMode) { + if (document.compatMode === "CSS1Compat") { + docMode = 7; // standards mode + } + } + } + } + return docMode; + }; + $.jPlayer.browser.documentMode = $.jPlayer.getDocMode(); + + $.jPlayer.nativeFeatures = { + init: function() { + + /* Fullscreen function naming influenced by W3C naming. + * No support for: Mozilla Proposal: https://wiki.mozilla.org/Gecko:FullScreenAPI + */ + + var d = document, + v = d.createElement('video'), + spec = { + // http://www.w3.org/TR/fullscreen/ + w3c: [ + 'fullscreenEnabled', + 'fullscreenElement', + 'requestFullscreen', + 'exitFullscreen', + 'fullscreenchange', + 'fullscreenerror' + ], + // https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode + moz: [ + 'mozFullScreenEnabled', + 'mozFullScreenElement', + 'mozRequestFullScreen', + 'mozCancelFullScreen', + 'mozfullscreenchange', + 'mozfullscreenerror' + ], + // http://developer.apple.com/library/safari/#documentation/WebKit/Reference/ElementClassRef/Element/Element.html + // http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html + webkit: [ + '', + 'webkitCurrentFullScreenElement', + 'webkitRequestFullScreen', + 'webkitCancelFullScreen', + 'webkitfullscreenchange', + '' + ], + // http://developer.apple.com/library/safari/#documentation/AudioVideo/Reference/HTMLVideoElementClassReference/HTMLVideoElement/HTMLVideoElement.html + // https://developer.apple.com/library/safari/samplecode/HTML5VideoEventFlow/Listings/events_js.html#//apple_ref/doc/uid/DTS40010085-events_js-DontLinkElementID_5 + // Events: 'webkitbeginfullscreen' and 'webkitendfullscreen' + webkitVideo: [ + 'webkitSupportsFullscreen', + 'webkitDisplayingFullscreen', + 'webkitEnterFullscreen', + 'webkitExitFullscreen', + '', + '' + ], + ms: [ + '', + 'msFullscreenElement', + 'msRequestFullscreen', + 'msExitFullscreen', + 'MSFullscreenChange', + 'MSFullscreenError' + ] + }, + specOrder = [ + 'w3c', + 'moz', + 'webkit', + 'webkitVideo', + 'ms' + ], + fs, i, il; + + this.fullscreen = fs = { + support: { + w3c: !!d[spec.w3c[0]], + moz: !!d[spec.moz[0]], + webkit: typeof d[spec.webkit[3]] === 'function', + webkitVideo: typeof v[spec.webkitVideo[2]] === 'function', + ms: typeof v[spec.ms[2]] === 'function' + }, + used: {} + }; + + // Store the name of the spec being used and as a handy boolean. + for(i = 0, il = specOrder.length; i < il; i++) { + var n = specOrder[i]; + if(fs.support[n]) { + fs.spec = n; + fs.used[n] = true; + break; + } + } + + if(fs.spec) { + var s = spec[fs.spec]; + fs.api = { + fullscreenEnabled: true, + fullscreenElement: function(elem) { + elem = elem ? elem : d; // Video element required for webkitVideo + return elem[s[1]]; + }, + requestFullscreen: function(elem) { + return elem[s[2]](); // Chrome and Opera want parameter (Element.ALLOW_KEYBOARD_INPUT) but Safari fails if flag used. + }, + exitFullscreen: function(elem) { + elem = elem ? elem : d; // Video element required for webkitVideo + return elem[s[3]](); + } + }; + fs.event = { + fullscreenchange: s[4], + fullscreenerror: s[5] + }; + } else { + fs.api = { + fullscreenEnabled: false, + fullscreenElement: function() { + return null; + }, + requestFullscreen: function() {}, + exitFullscreen: function() {} + }; + fs.event = {}; + } + } + }; + $.jPlayer.nativeFeatures.init(); + + // The keyboard control system. + + // The current jPlayer instance in focus. + $.jPlayer.focus = null; + + // The list of element node names to ignore with key controls. + $.jPlayer.keyIgnoreElementNames = "A INPUT TEXTAREA SELECT BUTTON"; + + // The function that deals with key presses. + var keyBindings = function(event) { + var f = $.jPlayer.focus, + ignoreKey; + key_pressing[event.key] = true; + // A jPlayer instance must be in focus. ie., keyEnabled and the last one played. + if(f && Object.keys(key_pressing).length==1) { + // What generated the key press? + $.each( $.jPlayer.keyIgnoreElementNames.split(/\s+/g), function(i, name) { + // The strings should already be uppercase. + if(event.target.nodeName.toUpperCase() === name.toUpperCase()) { + ignoreKey = true; + return false; // exit each. + } + }); + if(!ignoreKey) { + // See if the key pressed matches any of the bindings. + $.each(f.options.keyBindings, function(action, binding) { + // The binding could be a null when the default has been disabled. ie., 1st clause in if() + if( + (binding && $.isFunction(binding.fn)) && + ((typeof binding.key === 'number' && event.which === binding.key) || + (typeof binding.key === 'string' && event.key === binding.key)) + ) { + event.preventDefault(); // Key being used by jPlayer, so prevent default operation. + binding.fn(f); + return false; // exit each. + } + }); + } + } + }; + var key_pressing = {}; + $.jPlayer.keys = function(en) { + var event = "keydown.jPlayer"; + // Remove any binding, just in case enabled more than once. + $(document.documentElement).unbind(event); + if(en) { + $(document.documentElement).bind(event, keyBindings).bind("keyup.jPlayer", function(e){delete key_pressing[e.key]}); + } + }; + + // Enable the global key control handler ready for any jPlayer instance with the keyEnabled option enabled. + $.jPlayer.keys(true); + + $.jPlayer.prototype = { + count: 0, // Static Variable: Change it via prototype. + version: { // Static Object + script: "2.9.2", + needFlash: "2.9.0", + flash: "unknown" + }, + options: { // Instanced in $.jPlayer() constructor + swfPath: "js", // Path to jquery.jplayer.swf. Can be relative, absolute or server root relative. + solution: "html, flash", // Valid solutions: html, flash, aurora. Order defines priority. 1st is highest, + supplied: "mp3", // Defines which formats jPlayer will try and support and the priority by the order. 1st is highest, + auroraFormats: "wav", // List the aurora.js codecs being loaded externally. Its core supports "wav". Specify format in jPlayer context. EG., The aac.js codec gives the "m4a" format. + preload: 'metadata', // HTML5 Spec values: none, metadata, auto. + volume: 0.8, // The volume. Number 0 to 1. + muted: false, + remainingDuration: false, // When true, the remaining time is shown in the duration GUI element. + toggleDuration: false, // When true, clicks on the duration toggle between the duration and remaining display. + captureDuration: true, // When true, clicks on the duration are captured and no longer propagate up the DOM. + playbackRate: 1, + defaultPlaybackRate: 1, + minPlaybackRate: 0.5, + maxPlaybackRate: 4, + wmode: "opaque", // Valid wmode: window, transparent, opaque, direct, gpu. + backgroundColor: "#000000", // To define the jPlayer div and Flash background color. + cssSelectorAncestor: "#jp_container_1", + cssSelector: { // * denotes properties that should only be required when video media type required. _cssSelector() would require changes to enable splitting these into Audio and Video defaults. + videoPlay: ".jp-video-play", // * + play: ".jp-play", + pause: ".jp-pause", + stop: ".jp-stop", + seekBar: ".jp-seek-bar", + playBar: ".jp-play-bar", + mute: ".jp-mute", + unmute: ".jp-unmute", + volumeBar: ".jp-volume-bar", + volumeBarValue: ".jp-volume-bar-value", + volumeMax: ".jp-volume-max", + playbackRateBar: ".jp-playback-rate-bar", + playbackRateBarValue: ".jp-playback-rate-bar-value", + currentTime: ".jp-current-time", + duration: ".jp-duration", + title: ".jp-title", + fullScreen: ".jp-full-screen", // * + restoreScreen: ".jp-restore-screen", // * + repeat: ".jp-repeat", + repeatOff: ".jp-repeat-off", + gui: ".jp-gui", // The interface used with autohide feature. + noSolution: ".jp-no-solution" // For error feedback when jPlayer cannot find a solution. + }, + stateClass: { // Classes added to the cssSelectorAncestor to indicate the state. + playing: "jp-state-playing", + seeking: "jp-state-seeking", + muted: "jp-state-muted", + looped: "jp-state-looped", + fullScreen: "jp-state-full-screen", + noVolume: "jp-state-no-volume" + }, + useStateClassSkin: false, // A state class skin relies on the state classes to change the visual appearance. The single control toggles the effect, for example: play then pause, mute then unmute. + autoBlur: true, // GUI control handlers will drop focus after clicks. + smoothPlayBar: false, // Smooths the play bar transitions, which affects clicks and short media with big changes per second. + fullScreen: false, // Native Full Screen + fullWindow: false, + autohide: { + restored: false, // Controls the interface autohide feature. + full: true, // Controls the interface autohide feature. + fadeIn: 200, // Milliseconds. The period of the fadeIn anim. + fadeOut: 600, // Milliseconds. The period of the fadeOut anim. + hold: 1000 // Milliseconds. The period of the pause before autohide beings. + }, + loop: false, + repeat: function(event) { // The default jPlayer repeat event handler + if(event.jPlayer.options.loop) { + $(this).unbind(".jPlayerRepeat").bind($.jPlayer.event.ended + ".jPlayer.jPlayerRepeat", function() { + $(this).jPlayer("play"); + }); + } else { + $(this).unbind(".jPlayerRepeat"); + } + }, + nativeVideoControls: { + // Works well on standard browsers. + // Phone and tablet browsers can have problems with the controls disappearing. + }, + noFullWindow: { + msie: /msie [0-6]\./, + ipad: /ipad.*?os [0-4]\./, + iphone: /iphone/, + ipod: /ipod/, + android_pad: /android [0-3]\.(?!.*?mobile)/, + android_phone: /(?=.*android)(?!.*chrome)(?=.*mobile)/, + blackberry: /blackberry/, + windows_ce: /windows ce/, + iemobile: /iemobile/, + webos: /webos/ + }, + noVolume: { + ipad: /ipad/, + iphone: /iphone/, + ipod: /ipod/, + android_pad: /android(?!.*?mobile)/, + android_phone: /android.*?mobile/, + blackberry: /blackberry/, + windows_ce: /windows ce/, + iemobile: /iemobile/, + webos: /webos/, + playbook: /playbook/ + }, + timeFormat: { + // Specific time format for this instance. The supported options are defined in $.jPlayer.timeFormat + // For the undefined options we use the default from $.jPlayer.timeFormat + }, + keyEnabled: false, // Enables keyboard controls. + audioFullScreen: false, // Enables keyboard controls to enter full screen with audio media. + keyBindings: { // The key control object, defining the key codes and the functions to execute. + // The parameter, f = $.jPlayer.focus, will be checked truethy before attempting to call any of these functions. + // Properties may be added to this object, in key/fn pairs, to enable other key controls. EG, for the playlist add-on. + play: { + key: 80, // p + fn: function(f) { + if(f.status.paused) { + f.play(); + } else { + f.pause(); + } + } + }, + fullScreen: { + key: 70, // f + fn: function(f) { + if(f.status.video || f.options.audioFullScreen) { + f._setOption("fullScreen", !f.options.fullScreen); + } + } + }, + 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); + } + } + }, + verticalVolume: false, // Calculate volume from the bottom of the volume bar. Default is from the left. Also volume affects either width or height. + verticalPlaybackRate: false, + globalVolume: false, // Set to make volume and muted changes affect all jPlayer instances with this option enabled + idPrefix: "jp", // Prefix for the ids of html elements created by jPlayer. For flash, this must not include characters: . - + * / \ + noConflict: "jQuery", + emulateHtml: false, // Emulates the HTML5 Media element on the jPlayer element. + consoleAlerts: true, // Alerts are sent to the console.log() instead of alert(). + errorAlerts: false, + warningAlerts: false + }, + optionsAudio: { + size: { + width: "0px", + height: "0px", + cssClass: "" + }, + sizeFull: { + width: "0px", + height: "0px", + cssClass: "" + } + }, + optionsVideo: { + size: { + width: "480px", + height: "270px", + cssClass: "jp-video-270p" + }, + sizeFull: { + width: "100%", + height: "100%", + cssClass: "jp-video-full" + } + }, + instances: {}, // Static Object + status: { // Instanced in _init() + src: "", + media: {}, + paused: true, + format: {}, + formatType: "", + waitForPlay: true, // Same as waitForLoad except in case where preloading. + waitForLoad: true, + srcSet: false, + video: false, // True if playing a video + seekPercent: 0, + currentPercentRelative: 0, + currentPercentAbsolute: 0, + currentTime: 0, + duration: 0, + remaining: 0, + videoWidth: 0, // Intrinsic width of the video in pixels. + videoHeight: 0, // Intrinsic height of the video in pixels. + readyState: 0, + networkState: 0, + playbackRate: 1, // Warning - Now both an option and a status property + ended: 0 + +/* Persistant status properties created dynamically at _init(): + width + height + cssClass + nativeVideoControls + noFullWindow + noVolume + playbackRateEnabled // Warning - Technically, we can have both Flash and HTML, so this might not be correct if the Flash is active. That is a niche case. +*/ + }, + + internal: { // Instanced in _init() + ready: false + // instance: undefined + // domNode: undefined + // htmlDlyCmdId: undefined + // autohideId: undefined + // mouse: undefined + // cmdsIgnored + }, + solution: { // Static Object: Defines the solutions built in jPlayer. + html: true, + aurora: true, + flash: true + }, + // 'MPEG-4 support' : canPlayType('video/mp4; codecs="mp4v.20.8"') + format: { // Static Object + mp3: { + codec: 'audio/mpeg', + flashCanPlay: true, + media: 'audio' + }, + m4a: { // AAC / MP4 + codec: 'audio/mp4; codecs="mp4a.40.2"', + flashCanPlay: true, + media: 'audio' + }, + m3u8a: { // AAC / MP4 / Apple HLS + codec: 'application/vnd.apple.mpegurl; codecs="mp4a.40.2"', + flashCanPlay: false, + media: 'audio' + }, + m3ua: { // M3U + codec: 'audio/mpegurl', + flashCanPlay: false, + media: 'audio' + }, + oga: { // OGG + codec: 'audio/ogg; codecs="vorbis, opus"', + flashCanPlay: false, + media: 'audio' + }, + flac: { // FLAC + codec: 'audio/x-flac', + flashCanPlay: false, + media: 'audio' + }, + wav: { // PCM + codec: 'audio/wav; codecs="1"', + flashCanPlay: false, + media: 'audio' + }, + webma: { // WEBM + codec: 'audio/webm; codecs="vorbis"', + flashCanPlay: false, + media: 'audio' + }, + fla: { // FLV / F4A + codec: 'audio/x-flv', + flashCanPlay: true, + media: 'audio' + }, + rtmpa: { // RTMP AUDIO + codec: 'audio/rtmp; codecs="rtmp"', + flashCanPlay: true, + media: 'audio' + }, + m4v: { // H.264 / MP4 + codec: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', + flashCanPlay: true, + media: 'video' + }, + m3u8v: { // H.264 / AAC / MP4 / Apple HLS + codec: 'application/vnd.apple.mpegurl; codecs="avc1.42E01E, mp4a.40.2"', + flashCanPlay: false, + media: 'video' + }, + m3uv: { // M3U + codec: 'audio/mpegurl', + flashCanPlay: false, + media: 'video' + }, + ogv: { // OGG + codec: 'video/ogg; codecs="theora, vorbis"', + flashCanPlay: false, + media: 'video' + }, + webmv: { // WEBM + codec: 'video/webm; codecs="vorbis, vp8"', + flashCanPlay: false, + media: 'video' + }, + flv: { // FLV / F4V + codec: 'video/x-flv', + flashCanPlay: true, + media: 'video' + }, + rtmpv: { // RTMP VIDEO + codec: 'video/rtmp; codecs="rtmp"', + flashCanPlay: true, + media: 'video' + } + }, + _init: function() { + var self = this; + + this.element.empty(); + + this.status = $.extend({}, this.status); // Copy static to unique instance. + this.internal = $.extend({}, this.internal); // Copy static to unique instance. + + // Initialize the time format + this.options.timeFormat = $.extend({}, $.jPlayer.timeFormat, this.options.timeFormat); + + // On iOS, assume commands will be ignored before user initiates them. + this.internal.cmdsIgnored = $.jPlayer.platform.ipad || $.jPlayer.platform.iphone || $.jPlayer.platform.ipod; + + this.internal.domNode = this.element.get(0); + + // Add key bindings focus to 1st jPlayer instanced with key control enabled. + if(this.options.keyEnabled && !$.jPlayer.focus) { + $.jPlayer.focus = this; + } + + // A fix for Android where older (2.3) and even some 4.x devices fail to work when changing the *audio* SRC and then playing immediately. + this.androidFix = { + setMedia: false, // True when media set + play: false, // True when a progress event will instruct the media to play + pause: false, // True when a progress event will instruct the media to pause at a time. + time: NaN // The play(time) parameter + }; + if($.jPlayer.platform.android) { + this.options.preload = this.options.preload !== 'auto' ? 'metadata' : 'auto'; // Default to metadata, but allow auto. + } + + this.formats = []; // Array based on supplied string option. Order defines priority. + this.solutions = []; // Array based on solution string option. Order defines priority. + this.require = {}; // Which media types are required: video, audio. + + this.htmlElement = {}; // DOM elements created by jPlayer + this.html = {}; // In _init()'s this.desired code and setmedia(): Accessed via this[solution], where solution from this.solutions array. + this.html.audio = {}; + this.html.video = {}; + this.aurora = {}; // In _init()'s this.desired code and setmedia(): Accessed via this[solution], where solution from this.solutions array. + this.aurora.formats = []; + this.aurora.properties = []; + this.flash = {}; // In _init()'s this.desired code and setmedia(): Accessed via this[solution], where solution from this.solutions array. + + this.css = {}; + this.css.cs = {}; // Holds the css selector strings + this.css.jq = {}; // Holds jQuery selectors. ie., $(css.cs.method) + + this.ancestorJq = []; // Holds jQuery selector of cssSelectorAncestor. Init would use $() instead of [], but it is only 1.4+ + + this.options.volume = this._limitValue(this.options.volume, 0, 1); // Limit volume value's bounds. + + // Create the formats array, with prority based on the order of the supplied formats string + $.each(this.options.supplied.toLowerCase().split(","), function(index1, value1) { + var format = value1.replace(/^\s+|\s+$/g, ""); //trim + if(self.format[format]) { // Check format is valid. + var dupFound = false; + $.each(self.formats, function(index2, value2) { // Check for duplicates + if(format === value2) { + dupFound = true; + return false; + } + }); + if(!dupFound) { + self.formats.push(format); + } + } + }); + + // Create the solutions array, with prority based on the order of the solution string + $.each(this.options.solution.toLowerCase().split(","), function(index1, value1) { + var solution = value1.replace(/^\s+|\s+$/g, ""); //trim + if(self.solution[solution]) { // Check solution is valid. + var dupFound = false; + $.each(self.solutions, function(index2, value2) { // Check for duplicates + if(solution === value2) { + dupFound = true; + return false; + } + }); + if(!dupFound) { + self.solutions.push(solution); + } + } + }); + + // Create Aurora.js formats array + $.each(this.options.auroraFormats.toLowerCase().split(","), function(index1, value1) { + var format = value1.replace(/^\s+|\s+$/g, ""); //trim + if(self.format[format]) { // Check format is valid. + var dupFound = false; + $.each(self.aurora.formats, function(index2, value2) { // Check for duplicates + if(format === value2) { + dupFound = true; + return false; + } + }); + if(!dupFound) { + self.aurora.formats.push(format); + } + } + }); + + this.internal.instance = "jp_" + this.count; + this.instances[this.internal.instance] = this.element; + + // Check the jPlayer div has an id and create one if required. Important for Flash to know the unique id for comms. + if(!this.element.attr("id")) { + this.element.attr("id", this.options.idPrefix + "_jplayer_" + this.count); + } + + this.internal.self = $.extend({}, { + id: this.element.attr("id"), + jq: this.element + }); + this.internal.audio = $.extend({}, { + id: this.options.idPrefix + "_audio_" + this.count, + jq: undefined + }); + this.internal.video = $.extend({}, { + id: this.options.idPrefix + "_video_" + this.count, + jq: undefined + }); + this.internal.flash = $.extend({}, { + id: this.options.idPrefix + "_flash_" + this.count, + jq: undefined, + swf: this.options.swfPath + (this.options.swfPath.toLowerCase().slice(-4) !== ".swf" ? (this.options.swfPath && this.options.swfPath.slice(-1) !== "/" ? "/" : "") + "jquery.jplayer.swf" : "") + }); + this.internal.poster = $.extend({}, { + id: this.options.idPrefix + "_poster_" + this.count, + jq: undefined + }); + + // Register listeners defined in the constructor + $.each($.jPlayer.event, function(eventName,eventType) { + if(self.options[eventName] !== undefined) { + self.element.bind(eventType + ".jPlayer", self.options[eventName]); // With .jPlayer namespace. + self.options[eventName] = undefined; // Destroy the handler pointer copy on the options. Reason, events can be added/removed in other ways so this could be obsolete and misleading. + } + }); + + // Determine if we require solutions for audio, video or both media types. + this.require.audio = false; + this.require.video = false; + $.each(this.formats, function(priority, format) { + self.require[self.format[format].media] = true; + }); + + // Now required types are known, finish the options default settings. + if(this.require.video) { + this.options = $.extend(true, {}, + this.optionsVideo, + this.options + ); + } else { + this.options = $.extend(true, {}, + this.optionsAudio, + this.options + ); + } + this._setSize(); // update status and jPlayer element size + + // Determine the status for Blocklisted options. + this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls); + this.status.noFullWindow = this._uaBlocklist(this.options.noFullWindow); + this.status.noVolume = this._uaBlocklist(this.options.noVolume); + + // Create event handlers if native fullscreen is supported + if($.jPlayer.nativeFeatures.fullscreen.api.fullscreenEnabled) { + this._fullscreenAddEventListeners(); + } + + // The native controls are only for video and are disabled when audio is also used. + this._restrictNativeVideoControls(); + + // Create the poster image. + this.htmlElement.poster = document.createElement('img'); + this.htmlElement.poster.id = this.internal.poster.id; + this.htmlElement.poster.onload = function() { // Note that this did not work on Firefox 3.6: poster.addEventListener("onload", function() {}, false); Did not investigate x-browser. + if(!self.status.video || self.status.waitForPlay) { + self.internal.poster.jq.show(); + } + }; + this.element.append(this.htmlElement.poster); + this.internal.poster.jq = $("#" + this.internal.poster.id); + this.internal.poster.jq.css({'width': this.status.width, 'height': this.status.height}); + this.internal.poster.jq.hide(); + this.internal.poster.jq.bind("click.jPlayer", function() { + self._trigger($.jPlayer.event.click); + }); + + // Generate the required media elements + this.html.audio.available = false; + if(this.require.audio) { // If a supplied format is audio + this.htmlElement.audio = document.createElement('audio'); + this.htmlElement.audio.id = this.internal.audio.id; + this.html.audio.available = !!this.htmlElement.audio.canPlayType && this._testCanPlayType(this.htmlElement.audio); // Test is for IE9 on Win Server 2008. + } + this.html.video.available = false; + if(this.require.video) { // If a supplied format is video + this.htmlElement.video = document.createElement('video'); + this.htmlElement.video.id = this.internal.video.id; + this.html.video.available = !!this.htmlElement.video.canPlayType && this._testCanPlayType(this.htmlElement.video); // Test is for IE9 on Win Server 2008. + } + + this.flash.available = this._checkForFlash(10.1); + + this.html.canPlay = {}; + this.aurora.canPlay = {}; + this.flash.canPlay = {}; + $.each(this.formats, function(priority, format) { + self.html.canPlay[format] = self.html[self.format[format].media].available && "" !== self.htmlElement[self.format[format].media].canPlayType(self.format[format].codec); + self.aurora.canPlay[format] = ($.inArray(format, self.aurora.formats) > -1); + self.flash.canPlay[format] = self.format[format].flashCanPlay && self.flash.available; + }); + this.html.desired = false; + this.aurora.desired = false; + this.flash.desired = false; + $.each(this.solutions, function(solutionPriority, solution) { + if(solutionPriority === 0) { + self[solution].desired = true; + } else { + var audioCanPlay = false; + var videoCanPlay = false; + $.each(self.formats, function(formatPriority, format) { + if(self[self.solutions[0]].canPlay[format]) { // The other solution can play + if(self.format[format].media === 'video') { + videoCanPlay = true; + } else { + audioCanPlay = true; + } + } + }); + self[solution].desired = (self.require.audio && !audioCanPlay) || (self.require.video && !videoCanPlay); + } + }); + // This is what jPlayer will support, based on solution and supplied. + this.html.support = {}; + this.aurora.support = {}; + this.flash.support = {}; + $.each(this.formats, function(priority, format) { + self.html.support[format] = self.html.canPlay[format] && self.html.desired; + self.aurora.support[format] = self.aurora.canPlay[format] && self.aurora.desired; + self.flash.support[format] = self.flash.canPlay[format] && self.flash.desired; + }); + // If jPlayer is supporting any format in a solution, then the solution is used. + this.html.used = false; + this.aurora.used = false; + this.flash.used = false; + $.each(this.solutions, function(solutionPriority, solution) { + $.each(self.formats, function(formatPriority, format) { + if(self[solution].support[format]) { + self[solution].used = true; + return false; + } + }); + }); + + // Init solution active state and the event gates to false. + this._resetActive(); + this._resetGate(); + + // Set up the css selectors for the control and feedback entities. + this._cssSelectorAncestor(this.options.cssSelectorAncestor); + + // If neither html nor aurora nor flash are being used by this browser, then media playback is not possible. Trigger an error event. + if(!(this.html.used || this.aurora.used || this.flash.used)) { + this._error( { + type: $.jPlayer.error.NO_SOLUTION, + context: "{solution:'" + this.options.solution + "', supplied:'" + this.options.supplied + "'}", + message: $.jPlayer.errorMsg.NO_SOLUTION, + hint: $.jPlayer.errorHint.NO_SOLUTION + }); + if(this.css.jq.noSolution.length) { + this.css.jq.noSolution.show(); + } + } else { + if(this.css.jq.noSolution.length) { + this.css.jq.noSolution.hide(); + } + } + + // Add the flash solution if it is being used. + if(this.flash.used) { + var htmlObj, + flashVars = 'jQuery=' + encodeURI(this.options.noConflict) + '&id=' + encodeURI(this.internal.self.id) + '&vol=' + this.options.volume + '&muted=' + this.options.muted; + + // Code influenced by SWFObject 2.2: http://code.google.com/p/swfobject/ + // Non IE browsers have an initial Flash size of 1 by 1 otherwise the wmode affected the Flash ready event. + + if($.jPlayer.browser.msie && (Number($.jPlayer.browser.version) < 9 || $.jPlayer.browser.documentMode < 9)) { + var objStr = ''; + + var paramStr = [ + '', + '', + '', + '', + '' + ]; + + htmlObj = document.createElement(objStr); + for(var i=0; i < paramStr.length; i++) { + htmlObj.appendChild(document.createElement(paramStr[i])); + } + } else { + var createParam = function(el, n, v) { + var p = document.createElement("param"); + p.setAttribute("name", n); + p.setAttribute("value", v); + el.appendChild(p); + }; + + htmlObj = document.createElement("object"); + htmlObj.setAttribute("id", this.internal.flash.id); + htmlObj.setAttribute("name", this.internal.flash.id); + htmlObj.setAttribute("data", this.internal.flash.swf); + htmlObj.setAttribute("type", "application/x-shockwave-flash"); + htmlObj.setAttribute("width", "1"); // Non-zero + htmlObj.setAttribute("height", "1"); // Non-zero + htmlObj.setAttribute("tabindex", "-1"); + createParam(htmlObj, "flashvars", flashVars); + createParam(htmlObj, "allowscriptaccess", "always"); + createParam(htmlObj, "bgcolor", this.options.backgroundColor); + createParam(htmlObj, "wmode", this.options.wmode); + } + + this.element.append(htmlObj); + this.internal.flash.jq = $(htmlObj); + } + + // Setup playbackRate ability before using _addHtmlEventListeners() + if(this.html.used && !this.flash.used) { // If only HTML + // Using the audio element capabilities for playbackRate. ie., Assuming video element is the same. + this.status.playbackRateEnabled = this._testPlaybackRate('audio'); + } else { + this.status.playbackRateEnabled = false; + } + + this._updatePlaybackRate(); + + // Add the HTML solution if being used. + if(this.html.used) { + + // The HTML Audio handlers + if(this.html.audio.available) { + this._addHtmlEventListeners(this.htmlElement.audio, this.html.audio); + this.element.append(this.htmlElement.audio); + this.internal.audio.jq = $("#" + this.internal.audio.id); + } + + // The HTML Video handlers + if(this.html.video.available) { + this._addHtmlEventListeners(this.htmlElement.video, this.html.video); + this.element.append(this.htmlElement.video); + this.internal.video.jq = $("#" + this.internal.video.id); + if(this.status.nativeVideoControls) { + this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height}); + } else { + this.internal.video.jq.css({'width':'0px', 'height':'0px'}); // Using size 0x0 since a .hide() causes issues in iOS + } + this.internal.video.jq.bind("click.jPlayer", function() { + self._trigger($.jPlayer.event.click); + }); + } + } + + // Add the Aurora.js solution if being used. + if(this.aurora.used) { + // Aurora.js player need to be created for each media, see setMedia function. + } + + // Create the bridge that emulates the HTML Media element on the jPlayer DIV + if( this.options.emulateHtml ) { + this._emulateHtmlBridge(); + } + + if((this.html.used || this.aurora.used) && !this.flash.used) { // If only HTML, then emulate flash ready() call after 100ms. + setTimeout( function() { + self.internal.ready = true; + self.version.flash = "n/a"; + self._trigger($.jPlayer.event.repeat); // Trigger the repeat event so its handler can initialize itself with the loop option. + self._trigger($.jPlayer.event.ready); + }, 100); + } + + // Initialize the interface components with the options. + this._updateNativeVideoControls(); + // The other controls are now setup in _cssSelectorAncestor() + if(this.css.jq.videoPlay.length) { + this.css.jq.videoPlay.hide(); + } + + $.jPlayer.prototype.count++; // Change static variable via prototype. + }, + destroy: function() { + // MJP: The background change remains. Would need to store the original to restore it correctly. + // MJP: The jPlayer element's size change remains. + + // Clear the media to reset the GUI and stop any downloads. Streams on some browsers had persited. (Chrome) + this.clearMedia(); + // Remove the size/sizeFull cssClass from the cssSelectorAncestor + this._removeUiClass(); + // Remove the times from the GUI + if(this.css.jq.currentTime.length) { + this.css.jq.currentTime.text(""); + } + if(this.css.jq.duration.length) { + this.css.jq.duration.text(""); + } + // Remove any bindings from the interface controls. + $.each(this.css.jq, function(fn, jq) { + // Check selector is valid before trying to execute method. + if(jq.length) { + jq.unbind(".jPlayer"); + } + }); + // Remove the click handlers for $.jPlayer.event.click + this.internal.poster.jq.unbind(".jPlayer"); + if(this.internal.video.jq) { + this.internal.video.jq.unbind(".jPlayer"); + } + // Remove the fullscreen event handlers + this._fullscreenRemoveEventListeners(); + // Remove key bindings + if(this === $.jPlayer.focus) { + $.jPlayer.focus = null; + } + // Destroy the HTML bridge. + if(this.options.emulateHtml) { + this._destroyHtmlBridge(); + } + this.element.removeData("jPlayer"); // Remove jPlayer data + this.element.unbind(".jPlayer"); // Remove all event handlers created by the jPlayer constructor + this.element.empty(); // Remove the inserted child elements + + delete this.instances[this.internal.instance]; // Clear the instance on the static instance object + }, + destroyRemoved: function() { // Destroy any instances that have gone away. + var self = this; + $.each(this.instances, function(i, element) { + if(self.element !== element) { // Do not destroy this instance. + if(!element.data("jPlayer")) { // Check that element is a real jPlayer. + element.jPlayer("destroy"); + delete self.instances[i]; + } + } + }); + }, + enable: function() { // Plan to implement + // options.disabled = false + }, + disable: function () { // Plan to implement + // options.disabled = true + }, + _testCanPlayType: function(elem) { + // IE9 on Win Server 2008 did not implement canPlayType(), but it has the property. + try { + elem.canPlayType(this.format.mp3.codec); // The type is irrelevant. + return true; + } catch(err) { + return false; + } + }, + _testPlaybackRate: function(type) { + // type: String 'audio' or 'video' + var el, rate = 0.5; + type = typeof type === 'string' ? type : 'audio'; + el = document.createElement(type); + // Wrapping in a try/catch, just in case older HTML5 browsers throw and error. + try { + if('playbackRate' in el) { + el.playbackRate = rate; + return el.playbackRate === rate; + } else { + return false; + } + } catch(err) { + return false; + } + }, + _uaBlocklist: function(list) { + // list : object with properties that are all regular expressions. Property names are irrelevant. + // Returns true if the user agent is matched in list. + var ua = navigator.userAgent.toLowerCase(), + block = false; + + $.each(list, function(p, re) { + if(re && re.test(ua)) { + block = true; + return false; // exit $.each. + } + }); + return block; + }, + _restrictNativeVideoControls: function() { + // Fallback to noFullWindow when nativeVideoControls is true and audio media is being used. Affects when both media types are used. + if(this.require.audio) { + if(this.status.nativeVideoControls) { + this.status.nativeVideoControls = false; + this.status.noFullWindow = true; + } + } + }, + _updateNativeVideoControls: function() { + if(this.html.video.available && this.html.used) { + // Turn the HTML Video controls on/off + this.htmlElement.video.controls = this.status.nativeVideoControls; + // Show/hide the jPlayer GUI. + this._updateAutohide(); + // For when option changed. The poster image is not updated, as it is dealt with in setMedia(). Acceptable degradation since seriously doubt these options will change on the fly. Can again review later. + if(this.status.nativeVideoControls && this.require.video) { + this.internal.poster.jq.hide(); + this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height}); + } else if(this.status.waitForPlay && this.status.video) { + this.internal.poster.jq.show(); + this.internal.video.jq.css({'width': '0px', 'height': '0px'}); + } + } + }, + _addHtmlEventListeners: function(mediaElement, entity) { + var self = this; + mediaElement.preload = this.options.preload; + mediaElement.muted = this.options.muted; + mediaElement.volume = this.options.volume; + + if(this.status.playbackRateEnabled) { + mediaElement.defaultPlaybackRate = this.options.defaultPlaybackRate; + mediaElement.playbackRate = this.options.playbackRate; + } + + // Create the event listeners + // Only want the active entity to affect jPlayer and bubble events. + // Using entity.gate so that object is referenced and gate property always current + + mediaElement.addEventListener("progress", function() { + if(entity.gate) { + if(self.internal.cmdsIgnored && this.readyState > 0) { // Detect iOS executed the command + self.internal.cmdsIgnored = false; + } + self._getHtmlStatus(mediaElement); + self._updateInterface(); + self._trigger($.jPlayer.event.progress); + } + }, false); + mediaElement.addEventListener("loadeddata", function() { + if(entity.gate) { + self.androidFix.setMedia = false; // Disable the fix after the first progress event. + if(self.androidFix.play) { // Play Android audio - performing the fix. + self.androidFix.play = false; + self.play(self.androidFix.time); + } + if(self.androidFix.pause) { // Pause Android audio at time - performing the fix. + self.androidFix.pause = false; + self.pause(self.androidFix.time); + } + self._trigger($.jPlayer.event.loadeddata); + } + }, false); + mediaElement.addEventListener("timeupdate", function() { + if(entity.gate) { + self._getHtmlStatus(mediaElement); + self._updateInterface(); + self._trigger($.jPlayer.event.timeupdate); + } + }, false); + mediaElement.addEventListener("durationchange", function() { + if(entity.gate) { + self._getHtmlStatus(mediaElement); + self._updateInterface(); + self._trigger($.jPlayer.event.durationchange); + } + }, false); + mediaElement.addEventListener("play", function() { + if(entity.gate) { + self._updateButtons(true); + self._html_checkWaitForPlay(); // So the native controls update this variable and puts the hidden interface in the correct state. Affects toggling native controls. + self._trigger($.jPlayer.event.play); + } + }, false); + mediaElement.addEventListener("playing", function() { + if(entity.gate) { + self._updateButtons(true); + self._seeked(); + self._trigger($.jPlayer.event.playing); + } + }, false); + mediaElement.addEventListener("pause", function() { + if(entity.gate) { + self._updateButtons(false); + self._trigger($.jPlayer.event.pause); + } + }, false); + mediaElement.addEventListener("waiting", function() { + if(entity.gate) { + self._seeking(); + self._trigger($.jPlayer.event.waiting); + } + }, false); + mediaElement.addEventListener("seeking", function() { + if(entity.gate) { + self._seeking(); + self._trigger($.jPlayer.event.seeking); + } + }, false); + mediaElement.addEventListener("seeked", function() { + if(entity.gate) { + self._seeked(); + self._trigger($.jPlayer.event.seeked); + } + }, false); + mediaElement.addEventListener("volumechange", function() { + if(entity.gate) { + // Read the values back from the element as the Blackberry PlayBook shares the volume with the physical buttons master volume control. + // However, when tested 6th July 2011, those buttons do not generate an event. The physical play/pause button does though. + self.options.volume = mediaElement.volume; + self.options.muted = mediaElement.muted; + self._updateMute(); + self._updateVolume(); + self._trigger($.jPlayer.event.volumechange); + } + }, false); + mediaElement.addEventListener("ratechange", function() { + if(entity.gate) { + self.options.defaultPlaybackRate = mediaElement.defaultPlaybackRate; + self.options.playbackRate = mediaElement.playbackRate; + self._updatePlaybackRate(); + self._trigger($.jPlayer.event.ratechange); + } + }, false); + mediaElement.addEventListener("suspend", function() { // Seems to be the only way of capturing that the iOS4 browser did not actually play the media from the page code. ie., It needs a user gesture. + if(entity.gate) { + self._seeked(); + self._trigger($.jPlayer.event.suspend); + } + }, false); + mediaElement.addEventListener("ended", function() { + if(entity.gate) { + // Order of the next few commands are important. Change the time and then pause. + // Solves a bug in Firefox, where issuing pause 1st causes the media to play from the start. ie., The pause is ignored. + if(!$.jPlayer.browser.webkit) { // Chrome crashes if you do this in conjunction with a setMedia command in an ended event handler. ie., The playlist demo. + self.htmlElement.media.currentTime = 0; // Safari does not care about this command. ie., It works with or without this line. (Both Safari and Chrome are Webkit.) + } + self.htmlElement.media.pause(); // Pause otherwise a click on the progress bar will play from that point, when it shouldn't, since it stopped playback. + self._updateButtons(false); + self._getHtmlStatus(mediaElement, true); // With override true. Otherwise Chrome leaves progress at full. + self._updateInterface(); + self._trigger($.jPlayer.event.ended); + } + }, false); + mediaElement.addEventListener("error", function() { + if(entity.gate) { + self._updateButtons(false); + self._seeked(); + if(self.status.srcSet) { // Deals with case of clearMedia() causing an error event. + clearTimeout(self.internal.htmlDlyCmdId); // Clears any delayed commands used in the HTML solution. + self.status.waitForLoad = true; // Allows the load operation to try again. + self.status.waitForPlay = true; // Reset since a play was captured. + if(self.status.video && !self.status.nativeVideoControls) { + self.internal.video.jq.css({'width':'0px', 'height':'0px'}); + } + if(self._validString(self.status.media.poster) && !self.status.nativeVideoControls) { + self.internal.poster.jq.show(); + } + if(self.css.jq.videoPlay.length) { + self.css.jq.videoPlay.show(); + } + self._error( { + type: $.jPlayer.error.URL, + context: self.status.src, // this.src shows absolute urls. Want context to show the url given. + message: $.jPlayer.errorMsg.URL, + hint: $.jPlayer.errorHint.URL + }); + } + } + }, false); + // Create all the other event listeners that bubble up to a jPlayer event from html, without being used by jPlayer. + $.each($.jPlayer.htmlEvent, function(i, eventType) { + mediaElement.addEventListener(this, function() { + if(entity.gate) { + self._trigger($.jPlayer.event[eventType]); + } + }, false); + }); + }, + _addAuroraEventListeners : function(player, entity) { + var self = this; + //player.preload = this.options.preload; + //player.muted = this.options.muted; + player.volume = this.options.volume * 100; + + // Create the event listeners + // Only want the active entity to affect jPlayer and bubble events. + // Using entity.gate so that object is referenced and gate property always current + + player.on("progress", function() { + if(entity.gate) { + if(self.internal.cmdsIgnored && this.readyState > 0) { // Detect iOS executed the command + self.internal.cmdsIgnored = false; + } + self._getAuroraStatus(player); + self._updateInterface(); + self._trigger($.jPlayer.event.progress); + // Progress with song duration, we estimate timeupdate need to be triggered too. + if (player.duration > 0) { + self._trigger($.jPlayer.event.timeupdate); + } + } + }, false); + player.on("ready", function() { + if(entity.gate) { + self._trigger($.jPlayer.event.loadeddata); + } + }, false); + player.on("duration", function() { + if(entity.gate) { + self._getAuroraStatus(player); + self._updateInterface(); + self._trigger($.jPlayer.event.durationchange); + } + }, false); + player.on("end", function() { + if(entity.gate) { + // Order of the next few commands are important. Change the time and then pause. + self._updateButtons(false); + self._getAuroraStatus(player, true); + self._updateInterface(); + self._trigger($.jPlayer.event.ended); + } + }, false); + player.on("error", function() { + if(entity.gate) { + self._updateButtons(false); + self._seeked(); + if(self.status.srcSet) { // Deals with case of clearMedia() causing an error event. + self.status.waitForLoad = true; // Allows the load operation to try again. + self.status.waitForPlay = true; // Reset since a play was captured. + if(self.status.video && !self.status.nativeVideoControls) { + self.internal.video.jq.css({'width':'0px', 'height':'0px'}); + } + if(self._validString(self.status.media.poster) && !self.status.nativeVideoControls) { + self.internal.poster.jq.show(); + } + if(self.css.jq.videoPlay.length) { + self.css.jq.videoPlay.show(); + } + self._error( { + type: $.jPlayer.error.URL, + context: self.status.src, // this.src shows absolute urls. Want context to show the url given. + message: $.jPlayer.errorMsg.URL, + hint: $.jPlayer.errorHint.URL + }); + } + } + }, false); + }, + _getHtmlStatus: function(media, override) { + var ct = 0, cpa = 0, sp = 0, cpr = 0; + + // Fixes the duration bug in iOS, where the durationchange event occurs when media.duration is not always correct. + // Fixes the initial duration bug in BB OS7, where the media.duration is infinity and displays as NaN:NaN due to Date() using inifity. + if(isFinite(media.duration)) { + this.status.duration = media.duration; + } + + ct = media.currentTime; + cpa = (this.status.duration > 0) ? 100 * ct / this.status.duration : 0; + if((typeof media.seekable === "object") && (media.seekable.length > 0)) { + sp = (this.status.duration > 0) ? 100 * media.seekable.end(media.seekable.length-1) / this.status.duration : 100; + cpr = (this.status.duration > 0) ? 100 * media.currentTime / media.seekable.end(media.seekable.length-1) : 0; // Duration conditional for iOS duration bug. ie., seekable.end is a NaN in that case. + } else { + sp = 100; + cpr = cpa; + } + + if(override) { + ct = 0; + cpr = 0; + cpa = 0; + } + + this.status.seekPercent = sp; + this.status.currentPercentRelative = cpr; + this.status.currentPercentAbsolute = cpa; + this.status.currentTime = ct; + + this.status.remaining = this.status.duration - this.status.currentTime; + + this.status.videoWidth = media.videoWidth; + this.status.videoHeight = media.videoHeight; + + this.status.readyState = media.readyState; + this.status.networkState = media.networkState; + this.status.playbackRate = media.playbackRate; + this.status.ended = media.ended; + }, + _getAuroraStatus: function(player, override) { + var ct = 0, cpa = 0, sp = 0, cpr = 0; + + this.status.duration = player.duration / 1000; + + ct = player.currentTime / 1000; + cpa = (this.status.duration > 0) ? 100 * ct / this.status.duration : 0; + if(player.buffered > 0) { + sp = (this.status.duration > 0) ? (player.buffered * this.status.duration) / this.status.duration : 100; + cpr = (this.status.duration > 0) ? ct / (player.buffered * this.status.duration) : 0; + } else { + sp = 100; + cpr = cpa; + } + + if(override) { + ct = 0; + cpr = 0; + cpa = 0; + } + + this.status.seekPercent = sp; + this.status.currentPercentRelative = cpr; + this.status.currentPercentAbsolute = cpa; + this.status.currentTime = ct; + + this.status.remaining = this.status.duration - this.status.currentTime; + + this.status.readyState = 4; // status.readyState; + this.status.networkState = 0; // status.networkState; + this.status.playbackRate = 1; // status.playbackRate; + this.status.ended = false; // status.ended; + }, + _resetStatus: function() { + this.status = $.extend({}, this.status, $.jPlayer.prototype.status); // Maintains the status properties that persist through a reset. + }, + _trigger: function(eventType, error, warning) { // eventType always valid as called using $.jPlayer.event.eventType + var event = $.Event(eventType); + event.jPlayer = {}; + event.jPlayer.version = $.extend({}, this.version); + event.jPlayer.options = $.extend(true, {}, this.options); // Deep copy + event.jPlayer.status = $.extend(true, {}, this.status); // Deep copy + event.jPlayer.html = $.extend(true, {}, this.html); // Deep copy + event.jPlayer.aurora = $.extend(true, {}, this.aurora); // Deep copy + event.jPlayer.flash = $.extend(true, {}, this.flash); // Deep copy + if(error) { + event.jPlayer.error = $.extend({}, error); + } + if(warning) { + event.jPlayer.warning = $.extend({}, warning); + } + this.element.trigger(event); + }, + jPlayerFlashEvent: function(eventType, status) { // Called from Flash + if(eventType === $.jPlayer.event.ready) { + if(!this.internal.ready) { + this.internal.ready = true; + this.internal.flash.jq.css({'width':'0px', 'height':'0px'}); // Once Flash generates the ready event, minimise to zero as it is not affected by wmode anymore. + + this.version.flash = status.version; + if(this.version.needFlash !== this.version.flash) { + this._error( { + type: $.jPlayer.error.VERSION, + context: this.version.flash, + message: $.jPlayer.errorMsg.VERSION + this.version.flash, + hint: $.jPlayer.errorHint.VERSION + }); + } + this._trigger($.jPlayer.event.repeat); // Trigger the repeat event so its handler can initialize itself with the loop option. + this._trigger(eventType); + } else { + // This condition occurs if the Flash is hidden and then shown again. + // Firefox also reloads the Flash if the CSS position changes. position:fixed is used for full screen. + + // Only do this if the Flash is the solution being used at the moment. Affects Media players where both solution may be being used. + if(this.flash.gate) { + + // Send the current status to the Flash now that it is ready (available) again. + if(this.status.srcSet) { + + // Need to read original status before issuing the setMedia command. + var currentTime = this.status.currentTime, + paused = this.status.paused; + + this.setMedia(this.status.media); + this.volumeWorker(this.options.volume); + if(currentTime > 0) { + if(paused) { + this.pause(currentTime); + } else { + this.play(currentTime); + } + } + } + this._trigger($.jPlayer.event.flashreset); + } + } + } + if(this.flash.gate) { + switch(eventType) { + case $.jPlayer.event.progress: + this._getFlashStatus(status); + this._updateInterface(); + this._trigger(eventType); + break; + case $.jPlayer.event.timeupdate: + this._getFlashStatus(status); + this._updateInterface(); + this._trigger(eventType); + break; + case $.jPlayer.event.play: + this._seeked(); + this._updateButtons(true); + this._trigger(eventType); + break; + case $.jPlayer.event.pause: + this._updateButtons(false); + this._trigger(eventType); + break; + case $.jPlayer.event.ended: + this._updateButtons(false); + this._trigger(eventType); + break; + case $.jPlayer.event.click: + this._trigger(eventType); // This could be dealt with by the default + break; + case $.jPlayer.event.error: + this.status.waitForLoad = true; // Allows the load operation to try again. + this.status.waitForPlay = true; // Reset since a play was captured. + if(this.status.video) { + this.internal.flash.jq.css({'width':'0px', 'height':'0px'}); + } + if(this._validString(this.status.media.poster)) { + this.internal.poster.jq.show(); + } + if(this.css.jq.videoPlay.length && this.status.video) { + this.css.jq.videoPlay.show(); + } + if(this.status.video) { // Set up for another try. Execute before error event. + this._flash_setVideo(this.status.media); + } else { + this._flash_setAudio(this.status.media); + } + this._updateButtons(false); + this._error( { + type: $.jPlayer.error.URL, + context:status.src, + message: $.jPlayer.errorMsg.URL, + hint: $.jPlayer.errorHint.URL + }); + break; + case $.jPlayer.event.seeking: + this._seeking(); + this._trigger(eventType); + break; + case $.jPlayer.event.seeked: + this._seeked(); + this._trigger(eventType); + break; + case $.jPlayer.event.ready: + // The ready event is handled outside the switch statement. + // Captured here otherwise 2 ready events would be generated if the ready event handler used setMedia. + break; + default: + this._trigger(eventType); + } + } + return false; + }, + _getFlashStatus: function(status) { + this.status.seekPercent = status.seekPercent; + this.status.currentPercentRelative = status.currentPercentRelative; + this.status.currentPercentAbsolute = status.currentPercentAbsolute; + this.status.currentTime = status.currentTime; + this.status.duration = status.duration; + this.status.remaining = status.duration - status.currentTime; + + this.status.videoWidth = status.videoWidth; + this.status.videoHeight = status.videoHeight; + + // The Flash does not generate this information in this release + this.status.readyState = 4; // status.readyState; + this.status.networkState = 0; // status.networkState; + this.status.playbackRate = 1; // status.playbackRate; + this.status.ended = false; // status.ended; + }, + _updateButtons: function(playing) { + if(playing === undefined) { + playing = !this.status.paused; + } else { + this.status.paused = !playing; + } + // Apply the state classes. (For the useStateClassSkin:true option) + if(playing) { + this.addStateClass('playing'); + } else { + this.removeStateClass('playing'); + } + if(!this.status.noFullWindow && this.options.fullWindow) { + this.addStateClass('fullScreen'); + } else { + this.removeStateClass('fullScreen'); + } + if(this.options.loop) { + this.addStateClass('looped'); + } else { + this.removeStateClass('looped'); + } + // Toggle the GUI element pairs. (For the useStateClassSkin:false option) + if(this.css.jq.play.length && this.css.jq.pause.length) { + if(playing) { + this.css.jq.play.hide(); + this.css.jq.pause.show(); + } else { + this.css.jq.play.show(); + this.css.jq.pause.hide(); + } + } + if(this.css.jq.restoreScreen.length && this.css.jq.fullScreen.length) { + if(this.status.noFullWindow) { + this.css.jq.fullScreen.hide(); + this.css.jq.restoreScreen.hide(); + } else if(this.options.fullWindow) { + this.css.jq.fullScreen.hide(); + this.css.jq.restoreScreen.show(); + } else { + this.css.jq.fullScreen.show(); + this.css.jq.restoreScreen.hide(); + } + } + if(this.css.jq.repeat.length && this.css.jq.repeatOff.length) { + if(this.options.loop) { + this.css.jq.repeat.hide(); + this.css.jq.repeatOff.show(); + } else { + this.css.jq.repeat.show(); + this.css.jq.repeatOff.hide(); + } + } + }, + _updateInterface: function() { + if(this.css.jq.seekBar.length) { + this.css.jq.seekBar.width(this.status.seekPercent+"%"); + } + if(this.css.jq.playBar.length) { + if(this.options.smoothPlayBar) { + this.css.jq.playBar.stop().animate({ + width: this.status.currentPercentAbsolute+"%" + }, 250, "linear"); + } else { + this.css.jq.playBar.width(this.status.currentPercentRelative+"%"); + } + } + var currentTimeText = ''; + if(this.css.jq.currentTime.length) { + currentTimeText = this._convertTime(this.status.currentTime); + if(currentTimeText !== this.css.jq.currentTime.text()) { + this.css.jq.currentTime.text(this._convertTime(this.status.currentTime)); + } + } + var durationText = '', + duration = this.status.duration, + remaining = this.status.remaining; + if(this.css.jq.duration.length) { + if(typeof this.status.media.duration === 'string') { + durationText = this.status.media.duration; + } else { + if(typeof this.status.media.duration === 'number') { + duration = this.status.media.duration; + remaining = duration - this.status.currentTime; + } + if(this.options.remainingDuration) { + durationText = (remaining > 0 ? '-' : '') + this._convertTime(remaining); + } else { + durationText = this._convertTime(duration); + } + } + if(durationText !== this.css.jq.duration.text()) { + this.css.jq.duration.text(durationText); + } + } + }, + _convertTime: ConvertTime.prototype.time, + _seeking: function() { + if(this.css.jq.seekBar.length) { + this.css.jq.seekBar.addClass("jp-seeking-bg"); + } + this.addStateClass('seeking'); + }, + _seeked: function() { + if(this.css.jq.seekBar.length) { + this.css.jq.seekBar.removeClass("jp-seeking-bg"); + } + this.removeStateClass('seeking'); + }, + _resetGate: function() { + this.html.audio.gate = false; + this.html.video.gate = false; + this.aurora.gate = false; + this.flash.gate = false; + }, + _resetActive: function() { + this.html.active = false; + this.aurora.active = false; + this.flash.active = false; + }, + _escapeHtml: function(s) { + return s.split('&').join('&').split('<').join('<').split('>').join('>').split('"').join('"'); + }, + _qualifyURL: function(url) { + var el = document.createElement('div'); + el.innerHTML= 'x'; + return el.firstChild.href; + }, + _absoluteMediaUrls: function(media) { + var self = this; + $.each(media, function(type, url) { + if(url && self.format[type] && url.substr(0, 5) !== "data:") { + media[type] = self._qualifyURL(url); + } + }); + return media; + }, + addStateClass: function(state) { + if(this.ancestorJq.length) { + this.ancestorJq.addClass(this.options.stateClass[state]); + } + }, + removeStateClass: function(state) { + if(this.ancestorJq.length) { + this.ancestorJq.removeClass(this.options.stateClass[state]); + } + }, + setMedia: function(media) { + + /* media[format] = String: URL of format. Must contain all of the supplied option's video or audio formats. + * media.poster = String: Video poster URL. + * media.track = Array: Of objects defining the track element: kind, src, srclang, label, def. + * media.stream = Boolean: * NOT IMPLEMENTED * Designating actual media streams. ie., "false/undefined" for files. Plan to refresh the flash every so often. + */ + + var self = this, + supported = false, + posterChanged = this.status.media.poster !== media.poster; // Compare before reset. Important for OSX Safari as this.htmlElement.poster.src is absolute, even if original poster URL was relative. + + this._resetMedia(); + this._resetGate(); + this._resetActive(); + + // Clear the Android Fix. + this.androidFix.setMedia = false; + this.androidFix.play = false; + this.androidFix.pause = false; + + // Convert all media URLs to absolute URLs. + media = this._absoluteMediaUrls(media); + + $.each(this.formats, function(formatPriority, format) { + var isVideo = self.format[format].media === 'video'; + $.each(self.solutions, function(solutionPriority, solution) { + if(self[solution].support[format] && self._validString(media[format])) { // Format supported in solution and url given for format. + var isHtml = solution === 'html'; + var isAurora = solution === 'aurora'; + + if(isVideo) { + if(isHtml) { + self.html.video.gate = true; + self._html_setVideo(media); + self.html.active = true; + } else { + self.flash.gate = true; + self._flash_setVideo(media); + self.flash.active = true; + } + if(self.css.jq.videoPlay.length) { + self.css.jq.videoPlay.show(); + } + self.status.video = true; + } else { + if(isHtml) { + self.html.audio.gate = true; + self._html_setAudio(media); + self.html.active = true; + + // Setup the Android Fix - Only for HTML audio. + if($.jPlayer.platform.android) { + self.androidFix.setMedia = true; + } + } else if(isAurora) { + self.aurora.gate = true; + self._aurora_setAudio(media); + self.aurora.active = true; + } else { + self.flash.gate = true; + self._flash_setAudio(media); + self.flash.active = true; + } + if(self.css.jq.videoPlay.length) { + self.css.jq.videoPlay.hide(); + } + self.status.video = false; + } + + supported = true; + return false; // Exit $.each + } + }); + if(supported) { + return false; // Exit $.each + } + }); + + if(supported) { + if(!(this.status.nativeVideoControls && this.html.video.gate)) { + // Set poster IMG if native video controls are not being used + // Note: With IE the IMG onload event occurs immediately when cached. + // Note: Poster hidden by default in _resetMedia() + if(this._validString(media.poster)) { + if(posterChanged) { // Since some browsers do not generate img onload event. + this.htmlElement.poster.src = media.poster; + } else { + this.internal.poster.jq.show(); + } + } + } + if(typeof media.title === 'string') { + if(this.css.jq.title.length) { + this.css.jq.title.html(media.title); + } + if(this.htmlElement.audio) { + this.htmlElement.audio.setAttribute('title', media.title); + } + if(this.htmlElement.video) { + this.htmlElement.video.setAttribute('title', media.title); + } + } + this.status.srcSet = true; + this.status.media = $.extend({}, media); + this._updateButtons(false); + this._updateInterface(); + this._trigger($.jPlayer.event.setmedia); + } else { // jPlayer cannot support any formats provided in this browser + // Send an error event + this._error( { + type: $.jPlayer.error.NO_SUPPORT, + context: "{supplied:'" + this.options.supplied + "'}", + message: $.jPlayer.errorMsg.NO_SUPPORT, + hint: $.jPlayer.errorHint.NO_SUPPORT + }); + } + }, + _resetMedia: function() { + this._resetStatus(); + this._updateButtons(false); + this._updateInterface(); + this._seeked(); + this.internal.poster.jq.hide(); + + clearTimeout(this.internal.htmlDlyCmdId); + + if(this.html.active) { + this._html_resetMedia(); + } else if(this.aurora.active) { + this._aurora_resetMedia(); + } else if(this.flash.active) { + this._flash_resetMedia(); + } + }, + clearMedia: function() { + this._resetMedia(); + + if(this.html.active) { + this._html_clearMedia(); + } else if(this.aurora.active) { + this._aurora_clearMedia(); + } else if(this.flash.active) { + this._flash_clearMedia(); + } + + this._resetGate(); + this._resetActive(); + }, + load: function() { + if(this.status.srcSet) { + if(this.html.active) { + this._html_load(); + } else if(this.aurora.active) { + this._aurora_load(); + } else if(this.flash.active) { + this._flash_load(); + } + } else { + this._urlNotSetError("load"); + } + }, + focus: function() { + if(this.options.keyEnabled) { + $.jPlayer.focus = this; + } + }, + play: function(time) { + var guiAction = typeof time === "object"; // Flags GUI click events so we know this was not a direct command, but an action taken by the user on the GUI. + if(guiAction && this.options.useStateClassSkin && !this.status.paused) { + this.pause(time); // The time would be the click event, but passing it over so info is not lost. + } else { + time = (typeof time === "number") ? time : NaN; // Remove jQuery event from click handler + if(this.status.srcSet) { + this.focus(); + if(this.html.active) { + this._html_play(time); + } else if(this.aurora.active) { + this._aurora_play(time); + } else if(this.flash.active) { + this._flash_play(time); + } + } else { + this._urlNotSetError("play"); + } + } + }, + videoPlay: function() { // Handles clicks on the play button over the video poster + this.play(); + }, + pause: function(time) { + time = (typeof time === "number") ? time : NaN; // Remove jQuery event from click handler + if(this.status.srcSet) { + if(this.html.active) { + this._html_pause(time); + } else if(this.aurora.active) { + this._aurora_pause(time); + } else if(this.flash.active) { + this._flash_pause(time); + } + } else { + this._urlNotSetError("pause"); + } + }, + tellOthers: function(command, conditions) { + var self = this, + hasConditions = typeof conditions === 'function', + args = Array.prototype.slice.call(arguments); // Convert arguments to an Array. + + if(typeof command !== 'string') { // Ignore, since no command. + return; // Return undefined to maintain chaining. + } + if(hasConditions) { + args.splice(1, 1); // Remove the conditions from the arguments + } + + $.jPlayer.prototype.destroyRemoved(); + $.each(this.instances, function() { + // Remember that "this" is the instance's "element" in the $.each() loop. + if(self.element !== this) { // Do not tell my instance. + if(!hasConditions || conditions.call(this.data("jPlayer"), self)) { + this.jPlayer.apply(this, args); + } + } + }); + }, + pauseOthers: function(time) { + this.tellOthers("pause", function() { + // In the conditions function, the "this" context is the other instance's jPlayer object. + return this.status.srcSet; + }, time); + }, + stop: function() { + if(this.status.srcSet) { + if(this.html.active) { + this._html_pause(0); + } else if(this.aurora.active) { + this._aurora_pause(0); + } else if(this.flash.active) { + this._flash_pause(0); + } + } else { + this._urlNotSetError("stop"); + } + }, + playHead: function(p) { + p = this._limitValue(p, 0, 100); + if(this.status.srcSet) { + if(this.html.active) { + this._html_playHead(p); + } else if(this.aurora.active) { + this._aurora_playHead(p); + } else if(this.flash.active) { + this._flash_playHead(p); + } + } else { + this._urlNotSetError("playHead"); + } + }, + _muted: function(muted) { + this.mutedWorker(muted); + if(this.options.globalVolume) { + this.tellOthers("mutedWorker", function() { + // Check the other instance has global volume enabled. + return this.options.globalVolume; + }, muted); + } + }, + mutedWorker: function(muted) { + this.options.muted = muted; + if(this.html.used) { + this._html_setProperty('muted', muted); + } + if(this.aurora.used) { + this._aurora_mute(muted); + } + if(this.flash.used) { + this._flash_mute(muted); + } + + // The HTML solution generates this event from the media element itself. + if(!this.html.video.gate && !this.html.audio.gate) { + this._updateMute(muted); + this._updateVolume(this.options.volume); + this._trigger($.jPlayer.event.volumechange); + } + }, + mute: function(mute) { // mute is either: undefined (true), an event object (true) or a boolean (muted). + var guiAction = typeof mute === "object"; // Flags GUI click events so we know this was not a direct command, but an action taken by the user on the GUI. + if(guiAction && this.options.useStateClassSkin && this.options.muted) { + this._muted(false); + } else { + mute = mute === undefined ? true : !!mute; + this._muted(mute); + } + }, + unmute: function(unmute) { // unmute is either: undefined (true), an event object (true) or a boolean (!muted). + unmute = unmute === undefined ? true : !!unmute; + this._muted(!unmute); + }, + _updateMute: function(mute) { + if(mute === undefined) { + mute = this.options.muted; + } + if(mute) { + this.addStateClass('muted'); + } else { + this.removeStateClass('muted'); + } + if(this.css.jq.mute.length && this.css.jq.unmute.length) { + if(this.status.noVolume) { + this.css.jq.mute.hide(); + this.css.jq.unmute.hide(); + } else if(mute) { + this.css.jq.mute.hide(); + this.css.jq.unmute.show(); + } else { + this.css.jq.mute.show(); + this.css.jq.unmute.hide(); + } + } + }, + volume: function(v) { + this.volumeWorker(v); + if(this.options.globalVolume) { + this.tellOthers("volumeWorker", function() { + // Check the other instance has global volume enabled. + return this.options.globalVolume; + }, v); + } + }, + volumeWorker: function(v) { + v = this._limitValue(v, 0, 1); + this.options.volume = v; + + if(this.html.used) { + this._html_setProperty('volume', v); + } + if(this.aurora.used) { + this._aurora_volume(v); + } + if(this.flash.used) { + this._flash_volume(v); + } + + // The HTML solution generates this event from the media element itself. + if(!this.html.video.gate && !this.html.audio.gate) { + this._updateVolume(v); + this._trigger($.jPlayer.event.volumechange); + } + }, + volumeBar: function(e) { // Handles clicks on the volumeBar + if(this.css.jq.volumeBar.length) { + // Using $(e.currentTarget) to enable multiple volume bars + var $bar = $(e.currentTarget), + offset = $bar.offset(), + x = e.pageX - offset.left, + w = $bar.width(), + y = $bar.height() - e.pageY + offset.top, + h = $bar.height(); + if(this.options.verticalVolume) { + this.volume(y/h); + } else { + this.volume(x/w); + } + } + if(this.options.muted) { + this._muted(false); + } + }, + _updateVolume: function(v) { + if(v === undefined) { + v = this.options.volume; + } + v = this.options.muted ? 0 : v; + + if(this.status.noVolume) { + this.addStateClass('noVolume'); + if(this.css.jq.volumeBar.length) { + this.css.jq.volumeBar.hide(); + } + if(this.css.jq.volumeBarValue.length) { + this.css.jq.volumeBarValue.hide(); + } + if(this.css.jq.volumeMax.length) { + this.css.jq.volumeMax.hide(); + } + } else { + this.removeStateClass('noVolume'); + if(this.css.jq.volumeBar.length) { + this.css.jq.volumeBar.show(); + } + if(this.css.jq.volumeBarValue.length) { + this.css.jq.volumeBarValue.show(); + this.css.jq.volumeBarValue[this.options.verticalVolume ? "height" : "width"]((v*100)+"%"); + } + if(this.css.jq.volumeMax.length) { + this.css.jq.volumeMax.show(); + } + } + }, + volumeMax: function() { // Handles clicks on the volume max + this.volume(1); + if(this.options.muted) { + this._muted(false); + } + }, + _cssSelectorAncestor: function(ancestor) { + var self = this; + this.options.cssSelectorAncestor = ancestor; + this._removeUiClass(); + this.ancestorJq = ancestor ? $(ancestor) : []; // Would use $() instead of [], but it is only 1.4+ + if(ancestor && this.ancestorJq.length !== 1) { // So empty strings do not generate the warning. + this._warning( { + type: $.jPlayer.warning.CSS_SELECTOR_COUNT, + context: ancestor, + message: $.jPlayer.warningMsg.CSS_SELECTOR_COUNT + this.ancestorJq.length + " found for cssSelectorAncestor.", + hint: $.jPlayer.warningHint.CSS_SELECTOR_COUNT + }); + } + this._addUiClass(); + $.each(this.options.cssSelector, function(fn, cssSel) { + self._cssSelector(fn, cssSel); + }); + + // Set the GUI to the current state. + this._updateInterface(); + this._updateButtons(); + this._updateAutohide(); + this._updateVolume(); + this._updateMute(); + }, + _cssSelector: function(fn, cssSel) { + var self = this; + if(typeof cssSel === 'string') { + if($.jPlayer.prototype.options.cssSelector[fn]) { + if(this.css.jq[fn] && this.css.jq[fn].length) { + this.css.jq[fn].unbind(".jPlayer"); + } + this.options.cssSelector[fn] = cssSel; + this.css.cs[fn] = this.options.cssSelectorAncestor + " " + cssSel; + + if(cssSel) { // Checks for empty string + this.css.jq[fn] = $(this.css.cs[fn]); + } else { + this.css.jq[fn] = []; // To comply with the css.jq[fn].length check before its use. As of jQuery 1.4 could have used $() for an empty set. + } + + if(this.css.jq[fn].length && this[fn]) { + var handler = function(e) { + e.preventDefault(); + self[fn](e); + if(self.options.autoBlur) { + $(this).blur(); + } else { + $(this).focus(); // Force focus for ARIA. + } + }; + this.css.jq[fn].bind("click.jPlayer", handler); // Using jPlayer namespace + } + + if(cssSel && this.css.jq[fn].length !== 1) { // So empty strings do not generate the warning. ie., they just remove the old one. + this._warning( { + type: $.jPlayer.warning.CSS_SELECTOR_COUNT, + context: this.css.cs[fn], + message: $.jPlayer.warningMsg.CSS_SELECTOR_COUNT + this.css.jq[fn].length + " found for " + fn + " method.", + hint: $.jPlayer.warningHint.CSS_SELECTOR_COUNT + }); + } + } else { + this._warning( { + type: $.jPlayer.warning.CSS_SELECTOR_METHOD, + context: fn, + message: $.jPlayer.warningMsg.CSS_SELECTOR_METHOD, + hint: $.jPlayer.warningHint.CSS_SELECTOR_METHOD + }); + } + } else { + this._warning( { + type: $.jPlayer.warning.CSS_SELECTOR_STRING, + context: cssSel, + message: $.jPlayer.warningMsg.CSS_SELECTOR_STRING, + hint: $.jPlayer.warningHint.CSS_SELECTOR_STRING + }); + } + }, + duration: function(e) { + if(this.options.toggleDuration) { + if(this.options.captureDuration) { + e.stopPropagation(); + } + this._setOption("remainingDuration", !this.options.remainingDuration); + } + }, + seekBar: function(e) { // Handles clicks on the seekBar + if(this.css.jq.seekBar.length) { + // Using $(e.currentTarget) to enable multiple seek bars + var $bar = $(e.currentTarget), + offset = $bar.offset(), + x = e.pageX - offset.left, + w = $bar.width(), + p = 100 * x / w; + this.playHead(p); + } + }, + playbackRate: function(pbr) { + this._setOption("playbackRate", pbr); + }, + playbackRateBar: function(e) { // Handles clicks on the playbackRateBar + if(this.css.jq.playbackRateBar.length) { + // Using $(e.currentTarget) to enable multiple playbackRate bars + var $bar = $(e.currentTarget), + offset = $bar.offset(), + x = e.pageX - offset.left, + w = $bar.width(), + y = $bar.height() - e.pageY + offset.top, + h = $bar.height(), + ratio, pbr; + if(this.options.verticalPlaybackRate) { + ratio = y/h; + } else { + ratio = x/w; + } + pbr = ratio * (this.options.maxPlaybackRate - this.options.minPlaybackRate) + this.options.minPlaybackRate; + this.playbackRate(pbr); + } + }, + _updatePlaybackRate: function() { + var pbr = this.options.playbackRate, + ratio = (pbr - this.options.minPlaybackRate) / (this.options.maxPlaybackRate - this.options.minPlaybackRate); + if(this.status.playbackRateEnabled) { + if(this.css.jq.playbackRateBar.length) { + this.css.jq.playbackRateBar.show(); + } + if(this.css.jq.playbackRateBarValue.length) { + this.css.jq.playbackRateBarValue.show(); + this.css.jq.playbackRateBarValue[this.options.verticalPlaybackRate ? "height" : "width"]((ratio*100)+"%"); + } + } else { + if(this.css.jq.playbackRateBar.length) { + this.css.jq.playbackRateBar.hide(); + } + if(this.css.jq.playbackRateBarValue.length) { + this.css.jq.playbackRateBarValue.hide(); + } + } + }, + repeat: function(event) { // Handle clicks on the repeat button + var guiAction = typeof event === "object"; // Flags GUI click events so we know this was not a direct command, but an action taken by the user on the GUI. + if(guiAction && this.options.useStateClassSkin && this.options.loop) { + this._loop(false); + } else { + this._loop(true); + } + }, + repeatOff: function() { // Handle clicks on the repeatOff button + this._loop(false); + }, + _loop: function(loop) { + if(this.options.loop !== loop) { + this.options.loop = loop; + this._updateButtons(); + this._trigger($.jPlayer.event.repeat); + } + }, + + // Options code adapted from ui.widget.js (1.8.7). Made changes so the key can use dot notation. To match previous getData solution in jPlayer 1. + option: function(key, value) { + var options = key; + + // Enables use: options(). Returns a copy of options object + if ( arguments.length === 0 ) { + return $.extend( true, {}, this.options ); + } + + if(typeof key === "string") { + var keys = key.split("."); + + // Enables use: options("someOption") Returns a copy of the option. Supports dot notation. + if(value === undefined) { + + var opt = $.extend(true, {}, this.options); + for(var i = 0; i < keys.length; i++) { + if(opt[keys[i]] !== undefined) { + opt = opt[keys[i]]; + } else { + this._warning( { + type: $.jPlayer.warning.OPTION_KEY, + context: key, + message: $.jPlayer.warningMsg.OPTION_KEY, + hint: $.jPlayer.warningHint.OPTION_KEY + }); + return undefined; + } + } + return opt; + } + + // Enables use: options("someOptionObject", someObject}). Creates: {someOptionObject:someObject} + // Enables use: options("someOption", someValue). Creates: {someOption:someValue} + // Enables use: options("someOptionObject.someOption", someValue). Creates: {someOptionObject:{someOption:someValue}} + + options = {}; + var opts = options; + + for(var j = 0; j < keys.length; j++) { + if(j < keys.length - 1) { + opts[keys[j]] = {}; + opts = opts[keys[j]]; + } else { + opts[keys[j]] = value; + } + } + } + + // Otherwise enables use: options(optionObject). Uses original object (the key) + + this._setOptions(options); + + return this; + }, + _setOptions: function(options) { + var self = this; + $.each(options, function(key, value) { // This supports the 2 level depth that the options of jPlayer has. Would review if we ever need more depth. + self._setOption(key, value); + }); + + return this; + }, + _setOption: function(key, value) { + var self = this; + + // The ability to set options is limited at this time. + + switch(key) { + case "volume" : + this.volume(value); + break; + case "muted" : + this._muted(value); + break; + case "globalVolume" : + this.options[key] = value; + break; + case "cssSelectorAncestor" : + this._cssSelectorAncestor(value); // Set and refresh all associations for the new ancestor. + break; + case "cssSelector" : + $.each(value, function(fn, cssSel) { + self._cssSelector(fn, cssSel); // NB: The option is set inside this function, after further validity checks. + }); + break; + case "playbackRate" : + this.options[key] = value = this._limitValue(value, this.options.minPlaybackRate, this.options.maxPlaybackRate); + if(this.html.used) { + this._html_setProperty('playbackRate', value); + } + this._updatePlaybackRate(); + break; + case "defaultPlaybackRate" : + this.options[key] = value = this._limitValue(value, this.options.minPlaybackRate, this.options.maxPlaybackRate); + if(this.html.used) { + this._html_setProperty('defaultPlaybackRate', value); + } + this._updatePlaybackRate(); + break; + case "minPlaybackRate" : + this.options[key] = value = this._limitValue(value, 0.1, this.options.maxPlaybackRate - 0.1); + this._updatePlaybackRate(); + break; + case "maxPlaybackRate" : + this.options[key] = value = this._limitValue(value, this.options.minPlaybackRate + 0.1, 16); + this._updatePlaybackRate(); + break; + case "fullScreen" : + if(this.options[key] !== value) { // if changed + var wkv = $.jPlayer.nativeFeatures.fullscreen.used.webkitVideo; + if(!wkv || wkv && !this.status.waitForPlay) { + if(!wkv) { // No sensible way to unset option on these devices. + this.options[key] = value; + } + if(value) { + this._requestFullscreen(); + } else { + this._exitFullscreen(); + } + if(!wkv) { + this._setOption("fullWindow", value); + } + } + } + break; + case "fullWindow" : + if(this.options[key] !== value) { // if changed + this._removeUiClass(); + this.options[key] = value; + this._refreshSize(); + } + break; + case "size" : + if(!this.options.fullWindow && this.options[key].cssClass !== value.cssClass) { + this._removeUiClass(); + } + this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed. + this._refreshSize(); + break; + case "sizeFull" : + if(this.options.fullWindow && this.options[key].cssClass !== value.cssClass) { + this._removeUiClass(); + } + this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed. + this._refreshSize(); + break; + case "autohide" : + this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed. + this._updateAutohide(); + break; + case "loop" : + this._loop(value); + break; + case "remainingDuration" : + this.options[key] = value; + this._updateInterface(); + break; + case "toggleDuration" : + this.options[key] = value; + break; + case "nativeVideoControls" : + this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed. + this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls); + this._restrictNativeVideoControls(); + this._updateNativeVideoControls(); + break; + case "noFullWindow" : + this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed. + this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls); // Need to check again as noFullWindow can depend on this flag and the restrict() can override it. + this.status.noFullWindow = this._uaBlocklist(this.options.noFullWindow); + this._restrictNativeVideoControls(); + this._updateButtons(); + break; + case "noVolume" : + this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed. + this.status.noVolume = this._uaBlocklist(this.options.noVolume); + this._updateVolume(); + this._updateMute(); + break; + case "emulateHtml" : + if(this.options[key] !== value) { // To avoid multiple event handlers being created, if true already. + this.options[key] = value; + if(value) { + this._emulateHtmlBridge(); + } else { + this._destroyHtmlBridge(); + } + } + break; + case "timeFormat" : + this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed. + break; + case "keyEnabled" : + this.options[key] = value; + if(!value && this === $.jPlayer.focus) { + $.jPlayer.focus = null; + } + break; + case "keyBindings" : + this.options[key] = $.extend(true, {}, this.options[key], value); // store a merged DEEP copy of it, incase not all properties changed. + break; + case "audioFullScreen" : + this.options[key] = value; + break; + case "autoBlur" : + this.options[key] = value; + break; + } + + return this; + }, + // End of: (Options code adapted from ui.widget.js) + + _refreshSize: function() { + this._setSize(); // update status and jPlayer element size + this._addUiClass(); // update the ui class + this._updateSize(); // update internal sizes + this._updateButtons(); + this._updateAutohide(); + this._trigger($.jPlayer.event.resize); + }, + _setSize: function() { + // Determine the current size from the options + if(this.options.fullWindow) { + this.status.width = this.options.sizeFull.width; + this.status.height = this.options.sizeFull.height; + this.status.cssClass = this.options.sizeFull.cssClass; + } else { + this.status.width = this.options.size.width; + this.status.height = this.options.size.height; + this.status.cssClass = this.options.size.cssClass; + } + + // Set the size of the jPlayer area. + this.element.css({'width': this.status.width, 'height': this.status.height}); + }, + _addUiClass: function() { + if(this.ancestorJq.length) { + this.ancestorJq.addClass(this.status.cssClass); + } + }, + _removeUiClass: function() { + if(this.ancestorJq.length) { + this.ancestorJq.removeClass(this.status.cssClass); + } + }, + _updateSize: function() { + // The poster uses show/hide so can simply resize it. + this.internal.poster.jq.css({'width': this.status.width, 'height': this.status.height}); + + // Video html or flash resized if necessary at this time, or if native video controls being used. + if(!this.status.waitForPlay && this.html.active && this.status.video || this.html.video.available && this.html.used && this.status.nativeVideoControls) { + this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height}); + } + else if(!this.status.waitForPlay && this.flash.active && this.status.video) { + this.internal.flash.jq.css({'width': this.status.width, 'height': this.status.height}); + } + }, + _updateAutohide: function() { + var self = this, + event = "mousemove.jPlayer", + namespace = ".jPlayerAutohide", + eventType = event + namespace, + handler = function(event) { + var moved = false, + deltaX, deltaY; + if(typeof self.internal.mouse !== "undefined") { + //get the change from last position to this position + deltaX = self.internal.mouse.x - event.pageX; + deltaY = self.internal.mouse.y - event.pageY; + moved = (Math.floor(deltaX) > 0) || (Math.floor(deltaY)>0); + } else { + moved = true; + } + // store current position for next method execution + self.internal.mouse = { + x : event.pageX, + y : event.pageY + }; + // if mouse has been actually moved, do the gui fadeIn/fadeOut + if (moved) { + self.css.jq.gui.fadeIn(self.options.autohide.fadeIn, function() { + clearTimeout(self.internal.autohideId); + self.internal.autohideId = setTimeout( function() { + self.css.jq.gui.fadeOut(self.options.autohide.fadeOut); + }, self.options.autohide.hold); + }); + } + }; + + if(this.css.jq.gui.length) { + + // End animations first so that its callback is executed now. + // Otherwise an in progress fadeIn animation still has the callback to fadeOut again. + this.css.jq.gui.stop(true, true); + + // Removes the fadeOut operation from the fadeIn callback. + clearTimeout(this.internal.autohideId); + // undefine mouse + delete this.internal.mouse; + + this.element.unbind(namespace); + this.css.jq.gui.unbind(namespace); + + if(!this.status.nativeVideoControls) { + if(this.options.fullWindow && this.options.autohide.full || !this.options.fullWindow && this.options.autohide.restored) { + this.element.bind(eventType, handler); + this.css.jq.gui.bind(eventType, handler); + this.css.jq.gui.hide(); + } else { + this.css.jq.gui.show(); + } + } else { + this.css.jq.gui.hide(); + } + } + }, + fullScreen: function(event) { + var guiAction = typeof event === "object"; // Flags GUI click events so we know this was not a direct command, but an action taken by the user on the GUI. + if(guiAction && this.options.useStateClassSkin && this.options.fullScreen) { + this._setOption("fullScreen", false); + } else { + this._setOption("fullScreen", true); + } + }, + restoreScreen: function() { + this._setOption("fullScreen", false); + }, + _fullscreenAddEventListeners: function() { + var self = this, + fs = $.jPlayer.nativeFeatures.fullscreen; + + if(fs.api.fullscreenEnabled) { + if(fs.event.fullscreenchange) { + // Create the event handler function and store it for removal. + if(typeof this.internal.fullscreenchangeHandler !== 'function') { + this.internal.fullscreenchangeHandler = function() { + self._fullscreenchange(); + }; + } + document.addEventListener(fs.event.fullscreenchange, this.internal.fullscreenchangeHandler, false); + } + // No point creating handler for fullscreenerror. + // Either logic avoids fullscreen occurring (w3c/moz), or their is no event on the browser (webkit). + } + }, + _fullscreenRemoveEventListeners: function() { + var fs = $.jPlayer.nativeFeatures.fullscreen; + if(this.internal.fullscreenchangeHandler) { + document.removeEventListener(fs.event.fullscreenchange, this.internal.fullscreenchangeHandler, false); + } + }, + _fullscreenchange: function() { + // If nothing is fullscreen, then we cannot be in fullscreen mode. + if(this.options.fullScreen && !$.jPlayer.nativeFeatures.fullscreen.api.fullscreenElement()) { + this._setOption("fullScreen", false); + } + }, + _requestFullscreen: function() { + // Either the container or the jPlayer div + var e = this.ancestorJq.length ? this.ancestorJq[0] : this.element[0], + fs = $.jPlayer.nativeFeatures.fullscreen; + + // This method needs the video element. For iOS and Android. + if(fs.used.webkitVideo) { + e = this.htmlElement.video; + } + + if(fs.api.fullscreenEnabled) { + fs.api.requestFullscreen(e); + } + }, + _exitFullscreen: function() { + + var fs = $.jPlayer.nativeFeatures.fullscreen, + e; + + // This method needs the video element. For iOS and Android. + if(fs.used.webkitVideo) { + e = this.htmlElement.video; + } + + if(fs.api.fullscreenEnabled) { + fs.api.exitFullscreen(e); + } + }, + _html_initMedia: function(media) { + // Remove any existing track elements + var $media = $(this.htmlElement.media).empty(); + + // Create any track elements given with the media, as an Array of track Objects. + $.each(media.track || [], function(i,v) { + var track = document.createElement('track'); + track.setAttribute("kind", v.kind ? v.kind : ""); + track.setAttribute("src", v.src ? v.src : ""); + track.setAttribute("srclang", v.srclang ? v.srclang : ""); + track.setAttribute("label", v.label ? v.label : ""); + if(v.def) { + track.setAttribute("default", v.def); + } + $media.append(track); + }); + + this.htmlElement.media.src = this.status.src; + + if(this.options.preload !== 'none') { + this._html_load(); // See function for comments + } + this._trigger($.jPlayer.event.timeupdate); // The flash generates this event for its solution. + }, + _html_setFormat: function(media) { + var self = this; + // Always finds a format due to checks in setMedia() + $.each(this.formats, function(priority, format) { + if(self.html.support[format] && media[format]) { + self.status.src = media[format]; + self.status.format[format] = true; + self.status.formatType = format; + return false; + } + }); + }, + _html_setAudio: function(media) { + this._html_setFormat(media); + this.htmlElement.media = this.htmlElement.audio; + this._html_initMedia(media); + }, + _html_setVideo: function(media) { + this._html_setFormat(media); + if(this.status.nativeVideoControls) { + this.htmlElement.video.poster = this._validString(media.poster) ? media.poster : ""; + } + this.htmlElement.media = this.htmlElement.video; + this._html_initMedia(media); + }, + _html_resetMedia: function() { + if(this.htmlElement.media) { + if(this.htmlElement.media.id === this.internal.video.id && !this.status.nativeVideoControls) { + this.internal.video.jq.css({'width':'0px', 'height':'0px'}); + } + this.htmlElement.media.pause(); + } + }, + _html_clearMedia: function() { + if(this.htmlElement.media) { + this.htmlElement.media.src = "about:blank"; + // The following load() is only required for Firefox 3.6 (PowerMacs). + // Recent HTMl5 browsers only require the src change. Due to changes in W3C spec and load() effect. + this.htmlElement.media.load(); // Stops an old, "in progress" download from continuing the download. Triggers the loadstart, error and emptied events, due to the empty src. Also an abort event if a download was in progress. + } + }, + _html_load: function() { + // This function remains to allow the early HTML5 browsers to work, such as Firefox 3.6 + // A change in the W3C spec for the media.load() command means that this is no longer necessary. + // This command should be removed and actually causes minor undesirable effects on some browsers. Such as loading the whole file and not only the metadata. + if(this.status.waitForLoad) { + this.status.waitForLoad = false; + this.htmlElement.media.load(); + } + clearTimeout(this.internal.htmlDlyCmdId); + }, + _html_play: function(time) { + var self = this, + media = this.htmlElement.media; + + this.androidFix.pause = false; // Cancel the pause fix. + + this._html_load(); // Loads if required and clears any delayed commands. + + // Setup the Android Fix. + if(this.androidFix.setMedia) { + this.androidFix.play = true; + this.androidFix.time = time; + + } else if(!isNaN(time)) { + + // Attempt to play it, since iOS has been ignoring commands + if(this.internal.cmdsIgnored) { + media.play(); + } + + try { + // !media.seekable is for old HTML5 browsers, like Firefox 3.6. + // Checking seekable.length is important for iOS6 to work with setMedia().play(time) + if(!media.seekable || typeof media.seekable === "object" && media.seekable.length > 0) { + media.currentTime = time; + media.play(); + } else { + throw 1; + } + } catch(err) { + this.internal.htmlDlyCmdId = setTimeout(function() { + self.play(time); + }, 250); + return; // Cancel execution and wait for the delayed command. + } + } else { + media.play(); + } + this._html_checkWaitForPlay(); + }, + _html_pause: function(time) { + var self = this, + media = this.htmlElement.media; + + this.androidFix.play = false; // Cancel the play fix. + + if(time > 0) { // We do not want the stop() command, which does pause(0), causing a load operation. + this._html_load(); // Loads if required and clears any delayed commands. + } else { + clearTimeout(this.internal.htmlDlyCmdId); + } + + // Order of these commands is important for Safari (Win) and IE9. Pause then change currentTime. + media.pause(); + + // Setup the Android Fix. + if(this.androidFix.setMedia) { + this.androidFix.pause = true; + this.androidFix.time = time; + + } else if(!isNaN(time)) { + try { + if(!media.seekable || typeof media.seekable === "object" && media.seekable.length > 0) { + media.currentTime = time; + } else { + throw 1; + } + } catch(err) { + this.internal.htmlDlyCmdId = setTimeout(function() { + self.pause(time); + }, 250); + return; // Cancel execution and wait for the delayed command. + } + } + if(time > 0) { // Avoids a setMedia() followed by stop() or pause(0) hiding the video play button. + this._html_checkWaitForPlay(); + } + }, + _html_playHead: function(percent) { + var self = this, + media = this.htmlElement.media; + + this._html_load(); // Loads if required and clears any delayed commands. + + // This playHead() method needs a refactor to apply the android fix. + + try { + if(typeof media.seekable === "object" && media.seekable.length > 0) { + media.currentTime = percent * media.seekable.end(media.seekable.length-1) / 100; + } else if(media.duration > 0 && !isNaN(media.duration)) { + media.currentTime = percent * media.duration / 100; + } else { + throw "e"; + } + } catch(err) { + this.internal.htmlDlyCmdId = setTimeout(function() { + self.playHead(percent); + }, 250); + return; // Cancel execution and wait for the delayed command. + } + if(!this.status.waitForLoad) { + this._html_checkWaitForPlay(); + } + }, + _html_checkWaitForPlay: function() { + if(this.status.waitForPlay) { + this.status.waitForPlay = false; + if(this.css.jq.videoPlay.length) { + this.css.jq.videoPlay.hide(); + } + if(this.status.video) { + this.internal.poster.jq.hide(); + this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height}); + } + } + }, + _html_setProperty: function(property, value) { + if(this.html.audio.available) { + this.htmlElement.audio[property] = value; + } + if(this.html.video.available) { + this.htmlElement.video[property] = value; + } + }, + _aurora_setAudio: function(media) { + var self = this; + + // Always finds a format due to checks in setMedia() + $.each(this.formats, function(priority, format) { + if(self.aurora.support[format] && media[format]) { + self.status.src = media[format]; + self.status.format[format] = true; + self.status.formatType = format; + + return false; + } + }); + + this.aurora.player = new AV.Player.fromURL(this.status.src); + this._addAuroraEventListeners(this.aurora.player, this.aurora); + + if(this.options.preload === 'auto') { + this._aurora_load(); + this.status.waitForLoad = false; + } + }, + _aurora_resetMedia: function() { + if (this.aurora.player) { + this.aurora.player.stop(); + } + }, + _aurora_clearMedia: function() { + // Nothing to clear. + }, + _aurora_load: function() { + if(this.status.waitForLoad) { + this.status.waitForLoad = false; + this.aurora.player.preload(); + } + }, + _aurora_play: function(time) { + if (!this.status.waitForLoad) { + if (!isNaN(time)) { + this.aurora.player.seek(time); + } + } + if (!this.aurora.player.playing) { + this.aurora.player.play(); + } + this.status.waitForLoad = false; + this._aurora_checkWaitForPlay(); + + // No event from the player, update UI now. + this._updateButtons(true); + this._trigger($.jPlayer.event.play); + }, + _aurora_pause: function(time) { + if (!isNaN(time)) { + this.aurora.player.seek(time * 1000); + } + this.aurora.player.pause(); + + if(time > 0) { // Avoids a setMedia() followed by stop() or pause(0) hiding the video play button. + this._aurora_checkWaitForPlay(); + } + + // No event from the player, update UI now. + this._updateButtons(false); + this._trigger($.jPlayer.event.pause); + }, + _aurora_playHead: function(percent) { + if(this.aurora.player.duration > 0) { + // The seek() sould be in milliseconds, but the only codec that works with seek (aac.js) uses seconds. + this.aurora.player.seek(percent * this.aurora.player.duration / 100); // Using seconds + } + + if(!this.status.waitForLoad) { + this._aurora_checkWaitForPlay(); + } + }, + _aurora_checkWaitForPlay: function() { + if(this.status.waitForPlay) { + this.status.waitForPlay = false; + } + }, + _aurora_volume: function(v) { + this.aurora.player.volume = v * 100; + }, + _aurora_mute: function(m) { + if (m) { + this.aurora.properties.lastvolume = this.aurora.player.volume; + this.aurora.player.volume = 0; + } else { + this.aurora.player.volume = this.aurora.properties.lastvolume; + } + this.aurora.properties.muted = m; + }, + _flash_setAudio: function(media) { + var self = this; + try { + // Always finds a format due to checks in setMedia() + $.each(this.formats, function(priority, format) { + if(self.flash.support[format] && media[format]) { + switch (format) { + case "m4a" : + case "fla" : + self._getMovie().fl_setAudio_m4a(media[format]); + break; + case "mp3" : + self._getMovie().fl_setAudio_mp3(media[format]); + break; + case "rtmpa": + self._getMovie().fl_setAudio_rtmp(media[format]); + break; + } + self.status.src = media[format]; + self.status.format[format] = true; + self.status.formatType = format; + return false; + } + }); + + if(this.options.preload === 'auto') { + this._flash_load(); + this.status.waitForLoad = false; + } + } catch(err) { this._flashError(err); } + }, + _flash_setVideo: function(media) { + var self = this; + try { + // Always finds a format due to checks in setMedia() + $.each(this.formats, function(priority, format) { + if(self.flash.support[format] && media[format]) { + switch (format) { + case "m4v" : + case "flv" : + self._getMovie().fl_setVideo_m4v(media[format]); + break; + case "rtmpv": + self._getMovie().fl_setVideo_rtmp(media[format]); + break; + } + self.status.src = media[format]; + self.status.format[format] = true; + self.status.formatType = format; + return false; + } + }); + + if(this.options.preload === 'auto') { + this._flash_load(); + this.status.waitForLoad = false; + } + } catch(err) { this._flashError(err); } + }, + _flash_resetMedia: function() { + this.internal.flash.jq.css({'width':'0px', 'height':'0px'}); // Must do via CSS as setting attr() to zero causes a jQuery error in IE. + this._flash_pause(NaN); + }, + _flash_clearMedia: function() { + try { + this._getMovie().fl_clearMedia(); + } catch(err) { this._flashError(err); } + }, + _flash_load: function() { + try { + this._getMovie().fl_load(); + } catch(err) { this._flashError(err); } + this.status.waitForLoad = false; + }, + _flash_play: function(time) { + try { + this._getMovie().fl_play(time); + } catch(err) { this._flashError(err); } + this.status.waitForLoad = false; + this._flash_checkWaitForPlay(); + }, + _flash_pause: function(time) { + try { + this._getMovie().fl_pause(time); + } catch(err) { this._flashError(err); } + if(time > 0) { // Avoids a setMedia() followed by stop() or pause(0) hiding the video play button. + this.status.waitForLoad = false; + this._flash_checkWaitForPlay(); + } + }, + _flash_playHead: function(p) { + try { + this._getMovie().fl_play_head(p); + } catch(err) { this._flashError(err); } + if(!this.status.waitForLoad) { + this._flash_checkWaitForPlay(); + } + }, + _flash_checkWaitForPlay: function() { + if(this.status.waitForPlay) { + this.status.waitForPlay = false; + if(this.css.jq.videoPlay.length) { + this.css.jq.videoPlay.hide(); + } + if(this.status.video) { + this.internal.poster.jq.hide(); + this.internal.flash.jq.css({'width': this.status.width, 'height': this.status.height}); + } + } + }, + _flash_volume: function(v) { + try { + this._getMovie().fl_volume(v); + } catch(err) { this._flashError(err); } + }, + _flash_mute: function(m) { + try { + this._getMovie().fl_mute(m); + } catch(err) { this._flashError(err); } + }, + _getMovie: function() { + return document[this.internal.flash.id]; + }, + _getFlashPluginVersion: function() { + + // _getFlashPluginVersion() code influenced by: + // - FlashReplace 1.01: http://code.google.com/p/flashreplace/ + // - SWFObject 2.2: http://code.google.com/p/swfobject/ + + var version = 0, + flash; + if(window.ActiveXObject) { + try { + flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); + if (flash) { // flash will return null when ActiveX is disabled + var v = flash.GetVariable("$version"); + if(v) { + v = v.split(" ")[1].split(","); + version = parseInt(v[0], 10) + "." + parseInt(v[1], 10); + } + } + } catch(e) {} + } + else if(navigator.plugins && navigator.mimeTypes.length > 0) { + flash = navigator.plugins["Shockwave Flash"]; + if(flash) { + version = navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/, "$1"); + } + } + return version * 1; // Converts to a number + }, + _checkForFlash: function (version) { + var flashOk = false; + if(this._getFlashPluginVersion() >= version) { + flashOk = true; + } + return flashOk; + }, + _validString: function(url) { + return (url && typeof url === "string"); // Empty strings return false + }, + _limitValue: function(value, min, max) { + return (value < min) ? min : ((value > max) ? max : value); + }, + _urlNotSetError: function(context) { + this._error( { + type: $.jPlayer.error.URL_NOT_SET, + context: context, + message: $.jPlayer.errorMsg.URL_NOT_SET, + hint: $.jPlayer.errorHint.URL_NOT_SET + }); + }, + _flashError: function(error) { + var errorType; + if(!this.internal.ready) { + errorType = "FLASH"; + } else { + errorType = "FLASH_DISABLED"; + } + this._error( { + type: $.jPlayer.error[errorType], + context: this.internal.flash.swf, + message: $.jPlayer.errorMsg[errorType] + error.message, + hint: $.jPlayer.errorHint[errorType] + }); + // Allow the audio player to recover if display:none and then shown again, or with position:fixed on Firefox. + // This really only affects audio in a media player, as an audio player could easily move the jPlayer element away from such issues. + this.internal.flash.jq.css({'width':'1px', 'height':'1px'}); + }, + _error: function(error) { + this._trigger($.jPlayer.event.error, error); + if(this.options.errorAlerts) { + this._alert("Error!" + (error.message ? "\n" + error.message : "") + (error.hint ? "\n" + error.hint : "") + "\nContext: " + error.context); + } + }, + _warning: function(warning) { + this._trigger($.jPlayer.event.warning, undefined, warning); + if(this.options.warningAlerts) { + this._alert("Warning!" + (warning.message ? "\n" + warning.message : "") + (warning.hint ? "\n" + warning.hint : "") + "\nContext: " + warning.context); + } + }, + _alert: function(message) { + var msg = "jPlayer " + this.version.script + " : id='" + this.internal.self.id +"' : " + message; + if(!this.options.consoleAlerts) { + alert(msg); + } else if(window.console && window.console.log) { + window.console.log(msg); + } + }, + _emulateHtmlBridge: function() { + var self = this; + + // Emulate methods on jPlayer's DOM element. + $.each( $.jPlayer.emulateMethods.split(/\s+/g), function(i, name) { + self.internal.domNode[name] = function(arg) { + self[name](arg); + }; + + }); + + // Bubble jPlayer events to its DOM element. + $.each($.jPlayer.event, function(eventName,eventType) { + var nativeEvent = true; + $.each( $.jPlayer.reservedEvent.split(/\s+/g), function(i, name) { + if(name === eventName) { + nativeEvent = false; + return false; + } + }); + if(nativeEvent) { + self.element.bind(eventType + ".jPlayer.jPlayerHtml", function() { // With .jPlayer & .jPlayerHtml namespaces. + self._emulateHtmlUpdate(); + var domEvent = document.createEvent("Event"); + domEvent.initEvent(eventName, false, true); + self.internal.domNode.dispatchEvent(domEvent); + }); + } + // The error event would require a special case + }); + + // IE9 has a readyState property on all elements. The document should have it, but all (except media) elements inherit it in IE9. This conflicts with Popcorn, which polls the readyState. + }, + _emulateHtmlUpdate: function() { + var self = this; + + $.each( $.jPlayer.emulateStatus.split(/\s+/g), function(i, name) { + self.internal.domNode[name] = self.status[name]; + }); + $.each( $.jPlayer.emulateOptions.split(/\s+/g), function(i, name) { + self.internal.domNode[name] = self.options[name]; + }); + }, + _destroyHtmlBridge: function() { + var self = this; + + // Bridge event handlers are also removed by destroy() through .jPlayer namespace. + this.element.unbind(".jPlayerHtml"); // Remove all event handlers created by the jPlayer bridge. So you can change the emulateHtml option. + + // Remove the methods and properties + var emulated = $.jPlayer.emulateMethods + " " + $.jPlayer.emulateStatus + " " + $.jPlayer.emulateOptions; + $.each( emulated.split(/\s+/g), function(i, name) { + delete self.internal.domNode[name]; + }); + } + }; + + $.jPlayer.error = { + FLASH: "e_flash", + FLASH_DISABLED: "e_flash_disabled", + NO_SOLUTION: "e_no_solution", + NO_SUPPORT: "e_no_support", + URL: "e_url", + URL_NOT_SET: "e_url_not_set", + VERSION: "e_version" + }; + + $.jPlayer.errorMsg = { + FLASH: "jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ", // Used in: _flashError() + FLASH_DISABLED: "jPlayer's Flash fallback has been disabled by the browser due to the CSS rules you have used. Details: ", // Used in: _flashError() + NO_SOLUTION: "No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.", // Used in: _init() + NO_SUPPORT: "It is not possible to play any media format provided in setMedia() on this browser using your current options.", // Used in: setMedia() + URL: "Media URL could not be loaded.", // Used in: jPlayerFlashEvent() and _addHtmlEventListeners() + URL_NOT_SET: "Attempt to issue media playback commands, while no media url is set.", // Used in: load(), play(), pause(), stop() and playHead() + VERSION: "jPlayer " + $.jPlayer.prototype.version.script + " needs Jplayer.swf version " + $.jPlayer.prototype.version.needFlash + " but found " // Used in: jPlayerReady() + }; + + $.jPlayer.errorHint = { + FLASH: "Check your swfPath option and that Jplayer.swf is there.", + FLASH_DISABLED: "Check that you have not display:none; the jPlayer entity or any ancestor.", + NO_SOLUTION: "Review the jPlayer options: support and supplied.", + NO_SUPPORT: "Video or audio formats defined in the supplied option are missing.", + URL: "Check media URL is valid.", + URL_NOT_SET: "Use setMedia() to set the media URL.", + VERSION: "Update jPlayer files." + }; + + $.jPlayer.warning = { + CSS_SELECTOR_COUNT: "e_css_selector_count", + CSS_SELECTOR_METHOD: "e_css_selector_method", + CSS_SELECTOR_STRING: "e_css_selector_string", + OPTION_KEY: "e_option_key" + }; + + $.jPlayer.warningMsg = { + CSS_SELECTOR_COUNT: "The number of css selectors found did not equal one: ", + CSS_SELECTOR_METHOD: "The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.", + CSS_SELECTOR_STRING: "The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.", + OPTION_KEY: "The option requested in jPlayer('option') is undefined." + }; + + $.jPlayer.warningHint = { + CSS_SELECTOR_COUNT: "Check your css selector and the ancestor.", + CSS_SELECTOR_METHOD: "Check your method name.", + CSS_SELECTOR_STRING: "Check your css selector is a string.", + OPTION_KEY: "Check your option name." + }; +})); diff --git a/app/assets/javascripts/video_pro/jquery.jplayer.min.js b/app/assets/javascripts/video_pro/jquery.jplayer.min.js new file mode 100644 index 0000000..37f6c6c --- /dev/null +++ b/app/assets/javascripts/video_pro/jquery.jplayer.min.js @@ -0,0 +1,3 @@ +/*! jPlayer 2.9.2 for jQuery ~ (c) 2009-2014 Happyworm Ltd ~ MIT License */ +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b("object"==typeof exports?require("jquery"):a.jQuery?a.jQuery:a.Zepto)}(this,function(a,b){a.fn.jPlayer=function(c){var d="jPlayer",e="string"==typeof c,f=Array.prototype.slice.call(arguments,1),g=this;return c=!e&&f.length?a.extend.apply(null,[!0,c].concat(f)):c,e&&"_"===c.charAt(0)?g:(this.each(e?function(){var e=a(this).data(d),h=e&&a.isFunction(e[c])?e[c].apply(e,f):e;return h!==e&&h!==b?(g=h,!1):void 0}:function(){var b=a(this).data(d);b?b.option(c||{}):a(this).data(d,new a.jPlayer(c,this))}),g)},a.jPlayer=function(b,c){if(arguments.length){this.element=a(c),this.options=a.extend(!0,{},this.options,b);var d=this;this.element.bind("remove.jPlayer",function(){d.destroy()}),this._init()}},"function"!=typeof a.fn.stop&&(a.fn.stop=function(){}),a.jPlayer.emulateMethods="load play pause",a.jPlayer.emulateStatus="src readyState networkState currentTime duration paused ended playbackRate",a.jPlayer.emulateOptions="muted volume",a.jPlayer.reservedEvent="ready flashreset resize repeat error warning",a.jPlayer.event={},a.each(["ready","setmedia","flashreset","resize","repeat","click","error","warning","loadstart","progress","suspend","abort","emptied","stalled","play","pause","loadedmetadata","loadeddata","waiting","playing","canplay","canplaythrough","seeking","seeked","timeupdate","ended","ratechange","durationchange","volumechange"],function(){a.jPlayer.event[this]="jPlayer_"+this}),a.jPlayer.htmlEvent=["loadstart","abort","emptied","stalled","loadedmetadata","canplay","canplaythrough"],a.jPlayer.pause=function(){a.jPlayer.prototype.destroyRemoved(),a.each(a.jPlayer.prototype.instances,function(a,b){b.data("jPlayer").status.srcSet&&b.jPlayer("pause")})},a.jPlayer.timeFormat={showHour:!1,showMin:!0,showSec:!0,padHour:!1,padMin:!0,padSec:!0,sepHour:":",sepMin:":",sepSec:""};var c=function(){this.init()};c.prototype={init:function(){this.options={timeFormat:a.jPlayer.timeFormat}},time:function(a){a=a&&"number"==typeof a?a:0;var b=new Date(1e3*a),c=b.getUTCHours(),d=this.options.timeFormat.showHour?b.getUTCMinutes():b.getUTCMinutes()+60*c,e=this.options.timeFormat.showMin?b.getUTCSeconds():b.getUTCSeconds()+60*d,f=this.options.timeFormat.padHour&&10>c?"0"+c:c,g=this.options.timeFormat.padMin&&10>d?"0"+d:d,h=this.options.timeFormat.padSec&&10>e?"0"+e:e,i="";return i+=this.options.timeFormat.showHour?f+this.options.timeFormat.sepHour:"",i+=this.options.timeFormat.showMin?g+this.options.timeFormat.sepMin:"",i+=this.options.timeFormat.showSec?h+this.options.timeFormat.sepSec:""}};var d=new c;a.jPlayer.convertTime=function(a){return d.time(a)},a.jPlayer.uaBrowser=function(a){var b=a.toLowerCase(),c=/(webkit)[ \/]([\w.]+)/,d=/(opera)(?:.*version)?[ \/]([\w.]+)/,e=/(msie) ([\w.]+)/,f=/(mozilla)(?:.*? rv:([\w.]+))?/,g=c.exec(b)||d.exec(b)||e.exec(b)||b.indexOf("compatible")<0&&f.exec(b)||[];return{browser:g[1]||"",version:g[2]||"0"}},a.jPlayer.uaPlatform=function(a){var b=a.toLowerCase(),c=/(ipad|iphone|ipod|android|blackberry|playbook|windows ce|webos)/,d=/(ipad|playbook)/,e=/(android)/,f=/(mobile)/,g=c.exec(b)||[],h=d.exec(b)||!f.exec(b)&&e.exec(b)||[];return g[1]&&(g[1]=g[1].replace(/\s/g,"_")),{platform:g[1]||"",tablet:h[1]||""}},a.jPlayer.browser={},a.jPlayer.platform={};var e=a.jPlayer.uaBrowser(navigator.userAgent);e.browser&&(a.jPlayer.browser[e.browser]=!0,a.jPlayer.browser.version=e.version);var f=a.jPlayer.uaPlatform(navigator.userAgent);f.platform&&(a.jPlayer.platform[f.platform]=!0,a.jPlayer.platform.mobile=!f.tablet,a.jPlayer.platform.tablet=!!f.tablet),a.jPlayer.getDocMode=function(){var b;return a.jPlayer.browser.msie&&(document.documentMode?b=document.documentMode:(b=5,document.compatMode&&"CSS1Compat"===document.compatMode&&(b=7))),b},a.jPlayer.browser.documentMode=a.jPlayer.getDocMode(),a.jPlayer.nativeFeatures={init:function(){var a,b,c,d=document,e=d.createElement("video"),f={w3c:["fullscreenEnabled","fullscreenElement","requestFullscreen","exitFullscreen","fullscreenchange","fullscreenerror"],moz:["mozFullScreenEnabled","mozFullScreenElement","mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozfullscreenerror"],webkit:["","webkitCurrentFullScreenElement","webkitRequestFullScreen","webkitCancelFullScreen","webkitfullscreenchange",""],webkitVideo:["webkitSupportsFullscreen","webkitDisplayingFullscreen","webkitEnterFullscreen","webkitExitFullscreen","",""],ms:["","msFullscreenElement","msRequestFullscreen","msExitFullscreen","MSFullscreenChange","MSFullscreenError"]},g=["w3c","moz","webkit","webkitVideo","ms"];for(this.fullscreen=a={support:{w3c:!!d[f.w3c[0]],moz:!!d[f.moz[0]],webkit:"function"==typeof d[f.webkit[3]],webkitVideo:"function"==typeof e[f.webkitVideo[2]],ms:"function"==typeof e[f.ms[2]]},used:{}},b=0,c=g.length;c>b;b++){var h=g[b];if(a.support[h]){a.spec=h,a.used[h]=!0;break}}if(a.spec){var i=f[a.spec];a.api={fullscreenEnabled:!0,fullscreenElement:function(a){return a=a?a:d,a[i[1]]},requestFullscreen:function(a){return a[i[2]]()},exitFullscreen:function(a){return a=a?a:d,a[i[3]]()}},a.event={fullscreenchange:i[4],fullscreenerror:i[5]}}else a.api={fullscreenEnabled:!1,fullscreenElement:function(){return null},requestFullscreen:function(){},exitFullscreen:function(){}},a.event={}}},a.jPlayer.nativeFeatures.init(),a.jPlayer.focus=null,a.jPlayer.keyIgnoreElementNames="A INPUT TEXTAREA SELECT BUTTON";var g=function(b){var c,d=a.jPlayer.focus;key_pressing[event.key] = true;d&&Object.keys(key_pressing).length==1&&(a.each(a.jPlayer.keyIgnoreElementNames.split(/\s+/g),function(a,d){return b.target.nodeName.toUpperCase()===d.toUpperCase()?(c=!0,!1):void 0}),c||a.each(d.options.keyBindings,function(c,e){return e&&a.isFunction(e.fn)&&("number"==typeof e.key&&b.which===e.key||"string"==typeof e.key&&b.key===e.key)?(b.preventDefault(),e.fn(d),!1):void 0}))};var key_pressing = {};a.jPlayer.keys=function(b){var c="keydown.jPlayer";a(document.documentElement).unbind(c),b&&a(document.documentElement).bind(c,g).bind("keyup.jPlayer", function(e){delete key_pressing[e.key]})},a.jPlayer.keys(!0),a.jPlayer.prototype={count:0,version:{script:"2.9.2",needFlash:"2.9.0",flash:"unknown"},options:{swfPath:"js",solution:"html, flash",supplied:"mp3",auroraFormats:"wav",preload:"metadata",volume:.8,muted:!1,remainingDuration:!1,toggleDuration:!1,captureDuration:!0,playbackRate:1,defaultPlaybackRate:1,minPlaybackRate:.5,maxPlaybackRate:4,wmode:"opaque",backgroundColor:"#000000",cssSelectorAncestor:"#jp_container_1",cssSelector:{videoPlay:".jp-video-play",play:".jp-play",pause:".jp-pause",stop:".jp-stop",seekBar:".jp-seek-bar",playBar:".jp-play-bar",mute:".jp-mute",unmute:".jp-unmute",volumeBar:".jp-volume-bar",volumeBarValue:".jp-volume-bar-value",volumeMax:".jp-volume-max",playbackRateBar:".jp-playback-rate-bar",playbackRateBarValue:".jp-playback-rate-bar-value",currentTime:".jp-current-time",duration:".jp-duration",title:".jp-title",fullScreen:".jp-full-screen",restoreScreen:".jp-restore-screen",repeat:".jp-repeat",repeatOff:".jp-repeat-off",gui:".jp-gui",noSolution:".jp-no-solution"},stateClass:{playing:"jp-state-playing",seeking:"jp-state-seeking",muted:"jp-state-muted",looped:"jp-state-looped",fullScreen:"jp-state-full-screen",noVolume:"jp-state-no-volume"},useStateClassSkin:!1,autoBlur:!0,smoothPlayBar:!1,fullScreen:!1,fullWindow:!1,autohide:{restored:!1,full:!0,fadeIn:200,fadeOut:600,hold:1e3},loop:!1,repeat:function(b){b.jPlayer.options.loop?a(this).unbind(".jPlayerRepeat").bind(a.jPlayer.event.ended+".jPlayer.jPlayerRepeat",function(){a(this).jPlayer("play")}):a(this).unbind(".jPlayerRepeat")},nativeVideoControls:{},noFullWindow:{msie:/msie [0-6]\./,ipad:/ipad.*?os [0-4]\./,iphone:/iphone/,ipod:/ipod/,android_pad:/android [0-3]\.(?!.*?mobile)/,android_phone:/(?=.*android)(?!.*chrome)(?=.*mobile)/,blackberry:/blackberry/,windows_ce:/windows ce/,iemobile:/iemobile/,webos:/webos/},noVolume:{ipad:/ipad/,iphone:/iphone/,ipod:/ipod/,android_pad:/android(?!.*?mobile)/,android_phone:/android.*?mobile/,blackberry:/blackberry/,windows_ce:/windows ce/,iemobile:/iemobile/,webos:/webos/,playbook:/playbook/},timeFormat:{},keyEnabled:!1,audioFullScreen:!1,keyBindings:{play:{key:80,fn:function(a){a.status.paused?a.play():a.pause()}},fullScreen:{key:70,fn:function(a){(a.status.video||a.options.audioFullScreen)&&a._setOption("fullScreen",!a.options.fullScreen)}},muted:{key:77,fn:function(a){a._muted(!a.options.muted)}},volumeUp:{key:190,fn:function(a){a.volume(a.options.volume+.1)}},volumeDown:{key:188,fn:function(a){a.volume(a.options.volume-.1)}},loop:{key:76,fn:function(a){a._loop(!a.options.loop)}}},verticalVolume:!1,verticalPlaybackRate:!1,globalVolume:!1,idPrefix:"jp",noConflict:"jQuery",emulateHtml:!1,consoleAlerts:!0,errorAlerts:!1,warningAlerts:!1},optionsAudio:{size:{width:"0px",height:"0px",cssClass:""},sizeFull:{width:"0px",height:"0px",cssClass:""}},optionsVideo:{size:{width:"480px",height:"270px",cssClass:"jp-video-270p"},sizeFull:{width:"100%",height:"100%",cssClass:"jp-video-full"}},instances:{},status:{src:"",media:{},paused:!0,format:{},formatType:"",waitForPlay:!0,waitForLoad:!0,srcSet:!1,video:!1,seekPercent:0,currentPercentRelative:0,currentPercentAbsolute:0,currentTime:0,duration:0,remaining:0,videoWidth:0,videoHeight:0,readyState:0,networkState:0,playbackRate:1,ended:0},internal:{ready:!1},solution:{html:!0,aurora:!0,flash:!0},format:{mp3:{codec:"audio/mpeg",flashCanPlay:!0,media:"audio"},m4a:{codec:'audio/mp4; codecs="mp4a.40.2"',flashCanPlay:!0,media:"audio"},m3u8a:{codec:'application/vnd.apple.mpegurl; codecs="mp4a.40.2"',flashCanPlay:!1,media:"audio"},m3ua:{codec:"audio/mpegurl",flashCanPlay:!1,media:"audio"},oga:{codec:'audio/ogg; codecs="vorbis, opus"',flashCanPlay:!1,media:"audio"},flac:{codec:"audio/x-flac",flashCanPlay:!1,media:"audio"},wav:{codec:'audio/wav; codecs="1"',flashCanPlay:!1,media:"audio"},webma:{codec:'audio/webm; codecs="vorbis"',flashCanPlay:!1,media:"audio"},fla:{codec:"audio/x-flv",flashCanPlay:!0,media:"audio"},rtmpa:{codec:'audio/rtmp; codecs="rtmp"',flashCanPlay:!0,media:"audio"},m4v:{codec:'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',flashCanPlay:!0,media:"video"},m3u8v:{codec:'application/vnd.apple.mpegurl; codecs="avc1.42E01E, mp4a.40.2"',flashCanPlay:!1,media:"video"},m3uv:{codec:"audio/mpegurl",flashCanPlay:!1,media:"video"},ogv:{codec:'video/ogg; codecs="theora, vorbis"',flashCanPlay:!1,media:"video"},webmv:{codec:'video/webm; codecs="vorbis, vp8"',flashCanPlay:!1,media:"video"},flv:{codec:"video/x-flv",flashCanPlay:!0,media:"video"},rtmpv:{codec:'video/rtmp; codecs="rtmp"',flashCanPlay:!0,media:"video"}},_init:function(){var c=this;if(this.element.empty(),this.status=a.extend({},this.status),this.internal=a.extend({},this.internal),this.options.timeFormat=a.extend({},a.jPlayer.timeFormat,this.options.timeFormat),this.internal.cmdsIgnored=a.jPlayer.platform.ipad||a.jPlayer.platform.iphone||a.jPlayer.platform.ipod,this.internal.domNode=this.element.get(0),this.options.keyEnabled&&!a.jPlayer.focus&&(a.jPlayer.focus=this),this.androidFix={setMedia:!1,play:!1,pause:!1,time:0/0},a.jPlayer.platform.android&&(this.options.preload="auto"!==this.options.preload?"metadata":"auto"),this.formats=[],this.solutions=[],this.require={},this.htmlElement={},this.html={},this.html.audio={},this.html.video={},this.aurora={},this.aurora.formats=[],this.aurora.properties=[],this.flash={},this.css={},this.css.cs={},this.css.jq={},this.ancestorJq=[],this.options.volume=this._limitValue(this.options.volume,0,1),a.each(this.options.supplied.toLowerCase().split(","),function(b,d){var e=d.replace(/^\s+|\s+$/g,"");if(c.format[e]){var f=!1;a.each(c.formats,function(a,b){return e===b?(f=!0,!1):void 0}),f||c.formats.push(e)}}),a.each(this.options.solution.toLowerCase().split(","),function(b,d){var e=d.replace(/^\s+|\s+$/g,"");if(c.solution[e]){var f=!1;a.each(c.solutions,function(a,b){return e===b?(f=!0,!1):void 0}),f||c.solutions.push(e)}}),a.each(this.options.auroraFormats.toLowerCase().split(","),function(b,d){var e=d.replace(/^\s+|\s+$/g,"");if(c.format[e]){var f=!1;a.each(c.aurora.formats,function(a,b){return e===b?(f=!0,!1):void 0}),f||c.aurora.formats.push(e)}}),this.internal.instance="jp_"+this.count,this.instances[this.internal.instance]=this.element,this.element.attr("id")||this.element.attr("id",this.options.idPrefix+"_jplayer_"+this.count),this.internal.self=a.extend({},{id:this.element.attr("id"),jq:this.element}),this.internal.audio=a.extend({},{id:this.options.idPrefix+"_audio_"+this.count,jq:b}),this.internal.video=a.extend({},{id:this.options.idPrefix+"_video_"+this.count,jq:b}),this.internal.flash=a.extend({},{id:this.options.idPrefix+"_flash_"+this.count,jq:b,swf:this.options.swfPath+(".swf"!==this.options.swfPath.toLowerCase().slice(-4)?(this.options.swfPath&&"/"!==this.options.swfPath.slice(-1)?"/":"")+"jquery.jplayer.swf":"")}),this.internal.poster=a.extend({},{id:this.options.idPrefix+"_poster_"+this.count,jq:b}),a.each(a.jPlayer.event,function(a,d){c.options[a]!==b&&(c.element.bind(d+".jPlayer",c.options[a]),c.options[a]=b)}),this.require.audio=!1,this.require.video=!1,a.each(this.formats,function(a,b){c.require[c.format[b].media]=!0}),this.options=this.require.video?a.extend(!0,{},this.optionsVideo,this.options):a.extend(!0,{},this.optionsAudio,this.options),this._setSize(),this.status.nativeVideoControls=this._uaBlocklist(this.options.nativeVideoControls),this.status.noFullWindow=this._uaBlocklist(this.options.noFullWindow),this.status.noVolume=this._uaBlocklist(this.options.noVolume),a.jPlayer.nativeFeatures.fullscreen.api.fullscreenEnabled&&this._fullscreenAddEventListeners(),this._restrictNativeVideoControls(),this.htmlElement.poster=document.createElement("img"),this.htmlElement.poster.id=this.internal.poster.id,this.htmlElement.poster.onload=function(){(!c.status.video||c.status.waitForPlay)&&c.internal.poster.jq.show()},this.element.append(this.htmlElement.poster),this.internal.poster.jq=a("#"+this.internal.poster.id),this.internal.poster.jq.css({width:this.status.width,height:this.status.height}),this.internal.poster.jq.hide(),this.internal.poster.jq.bind("click.jPlayer",function(){c._trigger(a.jPlayer.event.click)}),this.html.audio.available=!1,this.require.audio&&(this.htmlElement.audio=document.createElement("audio"),this.htmlElement.audio.id=this.internal.audio.id,this.html.audio.available=!!this.htmlElement.audio.canPlayType&&this._testCanPlayType(this.htmlElement.audio)),this.html.video.available=!1,this.require.video&&(this.htmlElement.video=document.createElement("video"),this.htmlElement.video.id=this.internal.video.id,this.html.video.available=!!this.htmlElement.video.canPlayType&&this._testCanPlayType(this.htmlElement.video)),this.flash.available=this._checkForFlash(10.1),this.html.canPlay={},this.aurora.canPlay={},this.flash.canPlay={},a.each(this.formats,function(b,d){c.html.canPlay[d]=c.html[c.format[d].media].available&&""!==c.htmlElement[c.format[d].media].canPlayType(c.format[d].codec),c.aurora.canPlay[d]=a.inArray(d,c.aurora.formats)>-1,c.flash.canPlay[d]=c.format[d].flashCanPlay&&c.flash.available}),this.html.desired=!1,this.aurora.desired=!1,this.flash.desired=!1,a.each(this.solutions,function(b,d){if(0===b)c[d].desired=!0;else{var e=!1,f=!1;a.each(c.formats,function(a,b){c[c.solutions[0]].canPlay[b]&&("video"===c.format[b].media?f=!0:e=!0)}),c[d].desired=c.require.audio&&!e||c.require.video&&!f}}),this.html.support={},this.aurora.support={},this.flash.support={},a.each(this.formats,function(a,b){c.html.support[b]=c.html.canPlay[b]&&c.html.desired,c.aurora.support[b]=c.aurora.canPlay[b]&&c.aurora.desired,c.flash.support[b]=c.flash.canPlay[b]&&c.flash.desired}),this.html.used=!1,this.aurora.used=!1,this.flash.used=!1,a.each(this.solutions,function(b,d){a.each(c.formats,function(a,b){return c[d].support[b]?(c[d].used=!0,!1):void 0})}),this._resetActive(),this._resetGate(),this._cssSelectorAncestor(this.options.cssSelectorAncestor),this.html.used||this.aurora.used||this.flash.used?this.css.jq.noSolution.length&&this.css.jq.noSolution.hide():(this._error({type:a.jPlayer.error.NO_SOLUTION,context:"{solution:'"+this.options.solution+"', supplied:'"+this.options.supplied+"'}",message:a.jPlayer.errorMsg.NO_SOLUTION,hint:a.jPlayer.errorHint.NO_SOLUTION}),this.css.jq.noSolution.length&&this.css.jq.noSolution.show()),this.flash.used){var d,e="jQuery="+encodeURI(this.options.noConflict)+"&id="+encodeURI(this.internal.self.id)+"&vol="+this.options.volume+"&muted="+this.options.muted;if(a.jPlayer.browser.msie&&(Number(a.jPlayer.browser.version)<9||a.jPlayer.browser.documentMode<9)){var f='',g=['','','','',''];d=document.createElement(f);for(var h=0;h0&&(d.internal.cmdsIgnored=!1),d._getHtmlStatus(b),d._updateInterface(),d._trigger(a.jPlayer.event.progress))},!1),b.addEventListener("loadeddata",function(){c.gate&&(d.androidFix.setMedia=!1,d.androidFix.play&&(d.androidFix.play=!1,d.play(d.androidFix.time)),d.androidFix.pause&&(d.androidFix.pause=!1,d.pause(d.androidFix.time)),d._trigger(a.jPlayer.event.loadeddata))},!1),b.addEventListener("timeupdate",function(){c.gate&&(d._getHtmlStatus(b),d._updateInterface(),d._trigger(a.jPlayer.event.timeupdate))},!1),b.addEventListener("durationchange",function(){c.gate&&(d._getHtmlStatus(b),d._updateInterface(),d._trigger(a.jPlayer.event.durationchange))},!1),b.addEventListener("play",function(){c.gate&&(d._updateButtons(!0),d._html_checkWaitForPlay(),d._trigger(a.jPlayer.event.play))},!1),b.addEventListener("playing",function(){c.gate&&(d._updateButtons(!0),d._seeked(),d._trigger(a.jPlayer.event.playing))},!1),b.addEventListener("pause",function(){c.gate&&(d._updateButtons(!1),d._trigger(a.jPlayer.event.pause))},!1),b.addEventListener("waiting",function(){c.gate&&(d._seeking(),d._trigger(a.jPlayer.event.waiting))},!1),b.addEventListener("seeking",function(){c.gate&&(d._seeking(),d._trigger(a.jPlayer.event.seeking))},!1),b.addEventListener("seeked",function(){c.gate&&(d._seeked(),d._trigger(a.jPlayer.event.seeked))},!1),b.addEventListener("volumechange",function(){c.gate&&(d.options.volume=b.volume,d.options.muted=b.muted,d._updateMute(),d._updateVolume(),d._trigger(a.jPlayer.event.volumechange))},!1),b.addEventListener("ratechange",function(){c.gate&&(d.options.defaultPlaybackRate=b.defaultPlaybackRate,d.options.playbackRate=b.playbackRate,d._updatePlaybackRate(),d._trigger(a.jPlayer.event.ratechange))},!1),b.addEventListener("suspend",function(){c.gate&&(d._seeked(),d._trigger(a.jPlayer.event.suspend))},!1),b.addEventListener("ended",function(){c.gate&&(a.jPlayer.browser.webkit||(d.htmlElement.media.currentTime=0),d.htmlElement.media.pause(),d._updateButtons(!1),d._getHtmlStatus(b,!0),d._updateInterface(),d._trigger(a.jPlayer.event.ended))},!1),b.addEventListener("error",function(){c.gate&&(d._updateButtons(!1),d._seeked(),d.status.srcSet&&(clearTimeout(d.internal.htmlDlyCmdId),d.status.waitForLoad=!0,d.status.waitForPlay=!0,d.status.video&&!d.status.nativeVideoControls&&d.internal.video.jq.css({width:"0px",height:"0px"}),d._validString(d.status.media.poster)&&!d.status.nativeVideoControls&&d.internal.poster.jq.show(),d.css.jq.videoPlay.length&&d.css.jq.videoPlay.show(),d._error({type:a.jPlayer.error.URL,context:d.status.src,message:a.jPlayer.errorMsg.URL,hint:a.jPlayer.errorHint.URL})))},!1),a.each(a.jPlayer.htmlEvent,function(e,f){b.addEventListener(this,function(){c.gate&&d._trigger(a.jPlayer.event[f])},!1)})},_addAuroraEventListeners:function(b,c){var d=this;b.volume=100*this.options.volume,b.on("progress",function(){c.gate&&(d.internal.cmdsIgnored&&this.readyState>0&&(d.internal.cmdsIgnored=!1),d._getAuroraStatus(b),d._updateInterface(),d._trigger(a.jPlayer.event.progress),b.duration>0&&d._trigger(a.jPlayer.event.timeupdate))},!1),b.on("ready",function(){c.gate&&d._trigger(a.jPlayer.event.loadeddata)},!1),b.on("duration",function(){c.gate&&(d._getAuroraStatus(b),d._updateInterface(),d._trigger(a.jPlayer.event.durationchange))},!1),b.on("end",function(){c.gate&&(d._updateButtons(!1),d._getAuroraStatus(b,!0),d._updateInterface(),d._trigger(a.jPlayer.event.ended))},!1),b.on("error",function(){c.gate&&(d._updateButtons(!1),d._seeked(),d.status.srcSet&&(d.status.waitForLoad=!0,d.status.waitForPlay=!0,d.status.video&&!d.status.nativeVideoControls&&d.internal.video.jq.css({width:"0px",height:"0px"}),d._validString(d.status.media.poster)&&!d.status.nativeVideoControls&&d.internal.poster.jq.show(),d.css.jq.videoPlay.length&&d.css.jq.videoPlay.show(),d._error({type:a.jPlayer.error.URL,context:d.status.src,message:a.jPlayer.errorMsg.URL,hint:a.jPlayer.errorHint.URL})))},!1)},_getHtmlStatus:function(a,b){var c=0,d=0,e=0,f=0;isFinite(a.duration)&&(this.status.duration=a.duration),c=a.currentTime,d=this.status.duration>0?100*c/this.status.duration:0,"object"==typeof a.seekable&&a.seekable.length>0?(e=this.status.duration>0?100*a.seekable.end(a.seekable.length-1)/this.status.duration:100,f=this.status.duration>0?100*a.currentTime/a.seekable.end(a.seekable.length-1):0):(e=100,f=d),b&&(c=0,f=0,d=0),this.status.seekPercent=e,this.status.currentPercentRelative=f,this.status.currentPercentAbsolute=d,this.status.currentTime=c,this.status.remaining=this.status.duration-this.status.currentTime,this.status.videoWidth=a.videoWidth,this.status.videoHeight=a.videoHeight,this.status.readyState=a.readyState,this.status.networkState=a.networkState,this.status.playbackRate=a.playbackRate,this.status.ended=a.ended},_getAuroraStatus:function(a,b){var c=0,d=0,e=0,f=0;this.status.duration=a.duration/1e3,c=a.currentTime/1e3,d=this.status.duration>0?100*c/this.status.duration:0,a.buffered>0?(e=this.status.duration>0?a.buffered*this.status.duration/this.status.duration:100,f=this.status.duration>0?c/(a.buffered*this.status.duration):0):(e=100,f=d),b&&(c=0,f=0,d=0),this.status.seekPercent=e,this.status.currentPercentRelative=f,this.status.currentPercentAbsolute=d,this.status.currentTime=c,this.status.remaining=this.status.duration-this.status.currentTime,this.status.readyState=4,this.status.networkState=0,this.status.playbackRate=1,this.status.ended=!1},_resetStatus:function(){this.status=a.extend({},this.status,a.jPlayer.prototype.status)},_trigger:function(b,c,d){var e=a.Event(b);e.jPlayer={},e.jPlayer.version=a.extend({},this.version),e.jPlayer.options=a.extend(!0,{},this.options),e.jPlayer.status=a.extend(!0,{},this.status),e.jPlayer.html=a.extend(!0,{},this.html),e.jPlayer.aurora=a.extend(!0,{},this.aurora),e.jPlayer.flash=a.extend(!0,{},this.flash),c&&(e.jPlayer.error=a.extend({},c)),d&&(e.jPlayer.warning=a.extend({},d)),this.element.trigger(e)},jPlayerFlashEvent:function(b,c){if(b===a.jPlayer.event.ready)if(this.internal.ready){if(this.flash.gate){if(this.status.srcSet){var d=this.status.currentTime,e=this.status.paused;this.setMedia(this.status.media),this.volumeWorker(this.options.volume),d>0&&(e?this.pause(d):this.play(d))}this._trigger(a.jPlayer.event.flashreset)}}else this.internal.ready=!0,this.internal.flash.jq.css({width:"0px",height:"0px"}),this.version.flash=c.version,this.version.needFlash!==this.version.flash&&this._error({type:a.jPlayer.error.VERSION,context:this.version.flash,message:a.jPlayer.errorMsg.VERSION+this.version.flash,hint:a.jPlayer.errorHint.VERSION}),this._trigger(a.jPlayer.event.repeat),this._trigger(b);if(this.flash.gate)switch(b){case a.jPlayer.event.progress:this._getFlashStatus(c),this._updateInterface(),this._trigger(b);break;case a.jPlayer.event.timeupdate:this._getFlashStatus(c),this._updateInterface(),this._trigger(b);break;case a.jPlayer.event.play:this._seeked(),this._updateButtons(!0),this._trigger(b);break;case a.jPlayer.event.pause:this._updateButtons(!1),this._trigger(b);break;case a.jPlayer.event.ended:this._updateButtons(!1),this._trigger(b);break;case a.jPlayer.event.click:this._trigger(b);break;case a.jPlayer.event.error:this.status.waitForLoad=!0,this.status.waitForPlay=!0,this.status.video&&this.internal.flash.jq.css({width:"0px",height:"0px"}),this._validString(this.status.media.poster)&&this.internal.poster.jq.show(),this.css.jq.videoPlay.length&&this.status.video&&this.css.jq.videoPlay.show(),this.status.video?this._flash_setVideo(this.status.media):this._flash_setAudio(this.status.media),this._updateButtons(!1),this._error({type:a.jPlayer.error.URL,context:c.src,message:a.jPlayer.errorMsg.URL,hint:a.jPlayer.errorHint.URL});break;case a.jPlayer.event.seeking:this._seeking(),this._trigger(b);break;case a.jPlayer.event.seeked:this._seeked(),this._trigger(b);break;case a.jPlayer.event.ready:break;default:this._trigger(b)}return!1},_getFlashStatus:function(a){this.status.seekPercent=a.seekPercent,this.status.currentPercentRelative=a.currentPercentRelative,this.status.currentPercentAbsolute=a.currentPercentAbsolute,this.status.currentTime=a.currentTime,this.status.duration=a.duration,this.status.remaining=a.duration-a.currentTime,this.status.videoWidth=a.videoWidth,this.status.videoHeight=a.videoHeight,this.status.readyState=4,this.status.networkState=0,this.status.playbackRate=1,this.status.ended=!1},_updateButtons:function(a){a===b?a=!this.status.paused:this.status.paused=!a,a?this.addStateClass("playing"):this.removeStateClass("playing"),!this.status.noFullWindow&&this.options.fullWindow?this.addStateClass("fullScreen"):this.removeStateClass("fullScreen"),this.options.loop?this.addStateClass("looped"):this.removeStateClass("looped"),this.css.jq.play.length&&this.css.jq.pause.length&&(a?(this.css.jq.play.hide(),this.css.jq.pause.show()):(this.css.jq.play.show(),this.css.jq.pause.hide())),this.css.jq.restoreScreen.length&&this.css.jq.fullScreen.length&&(this.status.noFullWindow?(this.css.jq.fullScreen.hide(),this.css.jq.restoreScreen.hide()):this.options.fullWindow?(this.css.jq.fullScreen.hide(),this.css.jq.restoreScreen.show()):(this.css.jq.fullScreen.show(),this.css.jq.restoreScreen.hide())),this.css.jq.repeat.length&&this.css.jq.repeatOff.length&&(this.options.loop?(this.css.jq.repeat.hide(),this.css.jq.repeatOff.show()):(this.css.jq.repeat.show(),this.css.jq.repeatOff.hide()))},_updateInterface:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.width(this.status.seekPercent+"%"),this.css.jq.playBar.length&&(this.options.smoothPlayBar?this.css.jq.playBar.stop().animate({width:this.status.currentPercentAbsolute+"%"},250,"linear"):this.css.jq.playBar.width(this.status.currentPercentRelative+"%"));var a="";this.css.jq.currentTime.length&&(a=this._convertTime(this.status.currentTime),a!==this.css.jq.currentTime.text()&&this.css.jq.currentTime.text(this._convertTime(this.status.currentTime)));var b="",c=this.status.duration,d=this.status.remaining;this.css.jq.duration.length&&("string"==typeof this.status.media.duration?b=this.status.media.duration:("number"==typeof this.status.media.duration&&(c=this.status.media.duration,d=c-this.status.currentTime),b=this.options.remainingDuration?(d>0?"-":"")+this._convertTime(d):this._convertTime(c)),b!==this.css.jq.duration.text()&&this.css.jq.duration.text(b))},_convertTime:c.prototype.time,_seeking:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.addClass("jp-seeking-bg"),this.addStateClass("seeking")},_seeked:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.removeClass("jp-seeking-bg"),this.removeStateClass("seeking")},_resetGate:function(){this.html.audio.gate=!1,this.html.video.gate=!1,this.aurora.gate=!1,this.flash.gate=!1},_resetActive:function(){this.html.active=!1,this.aurora.active=!1,this.flash.active=!1},_escapeHtml:function(a){return a.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""")},_qualifyURL:function(a){var b=document.createElement("div"); +return b.innerHTML='x',b.firstChild.href},_absoluteMediaUrls:function(b){var c=this;return a.each(b,function(a,d){d&&c.format[a]&&"data:"!==d.substr(0,5)&&(b[a]=c._qualifyURL(d))}),b},addStateClass:function(a){this.ancestorJq.length&&this.ancestorJq.addClass(this.options.stateClass[a])},removeStateClass:function(a){this.ancestorJq.length&&this.ancestorJq.removeClass(this.options.stateClass[a])},setMedia:function(b){var c=this,d=!1,e=this.status.media.poster!==b.poster;this._resetMedia(),this._resetGate(),this._resetActive(),this.androidFix.setMedia=!1,this.androidFix.play=!1,this.androidFix.pause=!1,b=this._absoluteMediaUrls(b),a.each(this.formats,function(e,f){var g="video"===c.format[f].media;return a.each(c.solutions,function(e,h){if(c[h].support[f]&&c._validString(b[f])){var i="html"===h,j="aurora"===h;return g?(i?(c.html.video.gate=!0,c._html_setVideo(b),c.html.active=!0):(c.flash.gate=!0,c._flash_setVideo(b),c.flash.active=!0),c.css.jq.videoPlay.length&&c.css.jq.videoPlay.show(),c.status.video=!0):(i?(c.html.audio.gate=!0,c._html_setAudio(b),c.html.active=!0,a.jPlayer.platform.android&&(c.androidFix.setMedia=!0)):j?(c.aurora.gate=!0,c._aurora_setAudio(b),c.aurora.active=!0):(c.flash.gate=!0,c._flash_setAudio(b),c.flash.active=!0),c.css.jq.videoPlay.length&&c.css.jq.videoPlay.hide(),c.status.video=!1),d=!0,!1}}),d?!1:void 0}),d?(this.status.nativeVideoControls&&this.html.video.gate||this._validString(b.poster)&&(e?this.htmlElement.poster.src=b.poster:this.internal.poster.jq.show()),"string"==typeof b.title&&(this.css.jq.title.length&&this.css.jq.title.html(b.title),this.htmlElement.audio&&this.htmlElement.audio.setAttribute("title",b.title),this.htmlElement.video&&this.htmlElement.video.setAttribute("title",b.title)),this.status.srcSet=!0,this.status.media=a.extend({},b),this._updateButtons(!1),this._updateInterface(),this._trigger(a.jPlayer.event.setmedia)):this._error({type:a.jPlayer.error.NO_SUPPORT,context:"{supplied:'"+this.options.supplied+"'}",message:a.jPlayer.errorMsg.NO_SUPPORT,hint:a.jPlayer.errorHint.NO_SUPPORT})},_resetMedia:function(){this._resetStatus(),this._updateButtons(!1),this._updateInterface(),this._seeked(),this.internal.poster.jq.hide(),clearTimeout(this.internal.htmlDlyCmdId),this.html.active?this._html_resetMedia():this.aurora.active?this._aurora_resetMedia():this.flash.active&&this._flash_resetMedia()},clearMedia:function(){this._resetMedia(),this.html.active?this._html_clearMedia():this.aurora.active?this._aurora_clearMedia():this.flash.active&&this._flash_clearMedia(),this._resetGate(),this._resetActive()},load:function(){this.status.srcSet?this.html.active?this._html_load():this.aurora.active?this._aurora_load():this.flash.active&&this._flash_load():this._urlNotSetError("load")},focus:function(){this.options.keyEnabled&&(a.jPlayer.focus=this)},play:function(a){var b="object"==typeof a;b&&this.options.useStateClassSkin&&!this.status.paused?this.pause(a):(a="number"==typeof a?a:0/0,this.status.srcSet?(this.focus(),this.html.active?this._html_play(a):this.aurora.active?this._aurora_play(a):this.flash.active&&this._flash_play(a)):this._urlNotSetError("play"))},videoPlay:function(){this.play()},pause:function(a){a="number"==typeof a?a:0/0,this.status.srcSet?this.html.active?this._html_pause(a):this.aurora.active?this._aurora_pause(a):this.flash.active&&this._flash_pause(a):this._urlNotSetError("pause")},tellOthers:function(b,c){var d=this,e="function"==typeof c,f=Array.prototype.slice.call(arguments);"string"==typeof b&&(e&&f.splice(1,1),a.jPlayer.prototype.destroyRemoved(),a.each(this.instances,function(){d.element!==this&&(!e||c.call(this.data("jPlayer"),d))&&this.jPlayer.apply(this,f)}))},pauseOthers:function(a){this.tellOthers("pause",function(){return this.status.srcSet},a)},stop:function(){this.status.srcSet?this.html.active?this._html_pause(0):this.aurora.active?this._aurora_pause(0):this.flash.active&&this._flash_pause(0):this._urlNotSetError("stop")},playHead:function(a){a=this._limitValue(a,0,100),this.status.srcSet?this.html.active?this._html_playHead(a):this.aurora.active?this._aurora_playHead(a):this.flash.active&&this._flash_playHead(a):this._urlNotSetError("playHead")},_muted:function(a){this.mutedWorker(a),this.options.globalVolume&&this.tellOthers("mutedWorker",function(){return this.options.globalVolume},a)},mutedWorker:function(b){this.options.muted=b,this.html.used&&this._html_setProperty("muted",b),this.aurora.used&&this._aurora_mute(b),this.flash.used&&this._flash_mute(b),this.html.video.gate||this.html.audio.gate||(this._updateMute(b),this._updateVolume(this.options.volume),this._trigger(a.jPlayer.event.volumechange))},mute:function(a){var c="object"==typeof a;c&&this.options.useStateClassSkin&&this.options.muted?this._muted(!1):(a=a===b?!0:!!a,this._muted(a))},unmute:function(a){a=a===b?!0:!!a,this._muted(!a)},_updateMute:function(a){a===b&&(a=this.options.muted),a?this.addStateClass("muted"):this.removeStateClass("muted"),this.css.jq.mute.length&&this.css.jq.unmute.length&&(this.status.noVolume?(this.css.jq.mute.hide(),this.css.jq.unmute.hide()):a?(this.css.jq.mute.hide(),this.css.jq.unmute.show()):(this.css.jq.mute.show(),this.css.jq.unmute.hide()))},volume:function(a){this.volumeWorker(a),this.options.globalVolume&&this.tellOthers("volumeWorker",function(){return this.options.globalVolume},a)},volumeWorker:function(b){b=this._limitValue(b,0,1),this.options.volume=b,this.html.used&&this._html_setProperty("volume",b),this.aurora.used&&this._aurora_volume(b),this.flash.used&&this._flash_volume(b),this.html.video.gate||this.html.audio.gate||(this._updateVolume(b),this._trigger(a.jPlayer.event.volumechange))},volumeBar:function(b){if(this.css.jq.volumeBar.length){var c=a(b.currentTarget),d=c.offset(),e=b.pageX-d.left,f=c.width(),g=c.height()-b.pageY+d.top,h=c.height();this.volume(this.options.verticalVolume?g/h:e/f)}this.options.muted&&this._muted(!1)},_updateVolume:function(a){a===b&&(a=this.options.volume),a=this.options.muted?0:a,this.status.noVolume?(this.addStateClass("noVolume"),this.css.jq.volumeBar.length&&this.css.jq.volumeBar.hide(),this.css.jq.volumeBarValue.length&&this.css.jq.volumeBarValue.hide(),this.css.jq.volumeMax.length&&this.css.jq.volumeMax.hide()):(this.removeStateClass("noVolume"),this.css.jq.volumeBar.length&&this.css.jq.volumeBar.show(),this.css.jq.volumeBarValue.length&&(this.css.jq.volumeBarValue.show(),this.css.jq.volumeBarValue[this.options.verticalVolume?"height":"width"](100*a+"%")),this.css.jq.volumeMax.length&&this.css.jq.volumeMax.show())},volumeMax:function(){this.volume(1),this.options.muted&&this._muted(!1)},_cssSelectorAncestor:function(b){var c=this;this.options.cssSelectorAncestor=b,this._removeUiClass(),this.ancestorJq=b?a(b):[],b&&1!==this.ancestorJq.length&&this._warning({type:a.jPlayer.warning.CSS_SELECTOR_COUNT,context:b,message:a.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.ancestorJq.length+" found for cssSelectorAncestor.",hint:a.jPlayer.warningHint.CSS_SELECTOR_COUNT}),this._addUiClass(),a.each(this.options.cssSelector,function(a,b){c._cssSelector(a,b)}),this._updateInterface(),this._updateButtons(),this._updateAutohide(),this._updateVolume(),this._updateMute()},_cssSelector:function(b,c){var d=this;if("string"==typeof c)if(a.jPlayer.prototype.options.cssSelector[b]){if(this.css.jq[b]&&this.css.jq[b].length&&this.css.jq[b].unbind(".jPlayer"),this.options.cssSelector[b]=c,this.css.cs[b]=this.options.cssSelectorAncestor+" "+c,this.css.jq[b]=c?a(this.css.cs[b]):[],this.css.jq[b].length&&this[b]){var e=function(c){c.preventDefault(),d[b](c),d.options.autoBlur?a(this).blur():a(this).focus()};this.css.jq[b].bind("click.jPlayer",e)}c&&1!==this.css.jq[b].length&&this._warning({type:a.jPlayer.warning.CSS_SELECTOR_COUNT,context:this.css.cs[b],message:a.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.css.jq[b].length+" found for "+b+" method.",hint:a.jPlayer.warningHint.CSS_SELECTOR_COUNT})}else this._warning({type:a.jPlayer.warning.CSS_SELECTOR_METHOD,context:b,message:a.jPlayer.warningMsg.CSS_SELECTOR_METHOD,hint:a.jPlayer.warningHint.CSS_SELECTOR_METHOD});else this._warning({type:a.jPlayer.warning.CSS_SELECTOR_STRING,context:c,message:a.jPlayer.warningMsg.CSS_SELECTOR_STRING,hint:a.jPlayer.warningHint.CSS_SELECTOR_STRING})},duration:function(a){this.options.toggleDuration&&(this.options.captureDuration&&a.stopPropagation(),this._setOption("remainingDuration",!this.options.remainingDuration))},seekBar:function(b){if(this.css.jq.seekBar.length){var c=a(b.currentTarget),d=c.offset(),e=b.pageX-d.left,f=c.width(),g=100*e/f;this.playHead(g)}},playbackRate:function(a){this._setOption("playbackRate",a)},playbackRateBar:function(b){if(this.css.jq.playbackRateBar.length){var c,d,e=a(b.currentTarget),f=e.offset(),g=b.pageX-f.left,h=e.width(),i=e.height()-b.pageY+f.top,j=e.height();c=this.options.verticalPlaybackRate?i/j:g/h,d=c*(this.options.maxPlaybackRate-this.options.minPlaybackRate)+this.options.minPlaybackRate,this.playbackRate(d)}},_updatePlaybackRate:function(){var a=this.options.playbackRate,b=(a-this.options.minPlaybackRate)/(this.options.maxPlaybackRate-this.options.minPlaybackRate);this.status.playbackRateEnabled?(this.css.jq.playbackRateBar.length&&this.css.jq.playbackRateBar.show(),this.css.jq.playbackRateBarValue.length&&(this.css.jq.playbackRateBarValue.show(),this.css.jq.playbackRateBarValue[this.options.verticalPlaybackRate?"height":"width"](100*b+"%"))):(this.css.jq.playbackRateBar.length&&this.css.jq.playbackRateBar.hide(),this.css.jq.playbackRateBarValue.length&&this.css.jq.playbackRateBarValue.hide())},repeat:function(a){var b="object"==typeof a;this._loop(b&&this.options.useStateClassSkin&&this.options.loop?!1:!0)},repeatOff:function(){this._loop(!1)},_loop:function(b){this.options.loop!==b&&(this.options.loop=b,this._updateButtons(),this._trigger(a.jPlayer.event.repeat))},option:function(c,d){var e=c;if(0===arguments.length)return a.extend(!0,{},this.options);if("string"==typeof c){var f=c.split(".");if(d===b){for(var g=a.extend(!0,{},this.options),h=0;h0||Math.floor(d)>0):e=!0,a.internal.mouse={x:b.pageX,y:b.pageY},e&&a.css.jq.gui.fadeIn(a.options.autohide.fadeIn,function(){clearTimeout(a.internal.autohideId),a.internal.autohideId=setTimeout(function(){a.css.jq.gui.fadeOut(a.options.autohide.fadeOut)},a.options.autohide.hold)})};this.css.jq.gui.length&&(this.css.jq.gui.stop(!0,!0),clearTimeout(this.internal.autohideId),delete this.internal.mouse,this.element.unbind(c),this.css.jq.gui.unbind(c),this.status.nativeVideoControls?this.css.jq.gui.hide():this.options.fullWindow&&this.options.autohide.full||!this.options.fullWindow&&this.options.autohide.restored?(this.element.bind(d,e),this.css.jq.gui.bind(d,e),this.css.jq.gui.hide()):this.css.jq.gui.show())},fullScreen:function(a){var b="object"==typeof a;b&&this.options.useStateClassSkin&&this.options.fullScreen?this._setOption("fullScreen",!1):this._setOption("fullScreen",!0)},restoreScreen:function(){this._setOption("fullScreen",!1)},_fullscreenAddEventListeners:function(){var b=this,c=a.jPlayer.nativeFeatures.fullscreen;c.api.fullscreenEnabled&&c.event.fullscreenchange&&("function"!=typeof this.internal.fullscreenchangeHandler&&(this.internal.fullscreenchangeHandler=function(){b._fullscreenchange()}),document.addEventListener(c.event.fullscreenchange,this.internal.fullscreenchangeHandler,!1))},_fullscreenRemoveEventListeners:function(){var b=a.jPlayer.nativeFeatures.fullscreen;this.internal.fullscreenchangeHandler&&document.removeEventListener(b.event.fullscreenchange,this.internal.fullscreenchangeHandler,!1)},_fullscreenchange:function(){this.options.fullScreen&&!a.jPlayer.nativeFeatures.fullscreen.api.fullscreenElement()&&this._setOption("fullScreen",!1)},_requestFullscreen:function(){var b=this.ancestorJq.length?this.ancestorJq[0]:this.element[0],c=a.jPlayer.nativeFeatures.fullscreen;c.used.webkitVideo&&(b=this.htmlElement.video),c.api.fullscreenEnabled&&c.api.requestFullscreen(b)},_exitFullscreen:function(){var b,c=a.jPlayer.nativeFeatures.fullscreen;c.used.webkitVideo&&(b=this.htmlElement.video),c.api.fullscreenEnabled&&c.api.exitFullscreen(b)},_html_initMedia:function(b){var c=a(this.htmlElement.media).empty();a.each(b.track||[],function(a,b){var d=document.createElement("track");d.setAttribute("kind",b.kind?b.kind:""),d.setAttribute("src",b.src?b.src:""),d.setAttribute("srclang",b.srclang?b.srclang:""),d.setAttribute("label",b.label?b.label:""),b.def&&d.setAttribute("default",b.def),c.append(d)}),this.htmlElement.media.src=this.status.src,"none"!==this.options.preload&&this._html_load(),this._trigger(a.jPlayer.event.timeupdate)},_html_setFormat:function(b){var c=this;a.each(this.formats,function(a,d){return c.html.support[d]&&b[d]?(c.status.src=b[d],c.status.format[d]=!0,c.status.formatType=d,!1):void 0})},_html_setAudio:function(a){this._html_setFormat(a),this.htmlElement.media=this.htmlElement.audio,this._html_initMedia(a)},_html_setVideo:function(a){this._html_setFormat(a),this.status.nativeVideoControls&&(this.htmlElement.video.poster=this._validString(a.poster)?a.poster:""),this.htmlElement.media=this.htmlElement.video,this._html_initMedia(a)},_html_resetMedia:function(){this.htmlElement.media&&(this.htmlElement.media.id!==this.internal.video.id||this.status.nativeVideoControls||this.internal.video.jq.css({width:"0px",height:"0px"}),this.htmlElement.media.pause())},_html_clearMedia:function(){this.htmlElement.media&&(this.htmlElement.media.src="about:blank",this.htmlElement.media.load())},_html_load:function(){this.status.waitForLoad&&(this.status.waitForLoad=!1,this.htmlElement.media.load()),clearTimeout(this.internal.htmlDlyCmdId)},_html_play:function(a){var b=this,c=this.htmlElement.media;if(this.androidFix.pause=!1,this._html_load(),this.androidFix.setMedia)this.androidFix.play=!0,this.androidFix.time=a;else if(isNaN(a))c.play();else{this.internal.cmdsIgnored&&c.play();try{if(c.seekable&&!("object"==typeof c.seekable&&c.seekable.length>0))throw 1;c.currentTime=a,c.play()}catch(d){return void(this.internal.htmlDlyCmdId=setTimeout(function(){b.play(a)},250))}}this._html_checkWaitForPlay()},_html_pause:function(a){var b=this,c=this.htmlElement.media;if(this.androidFix.play=!1,a>0?this._html_load():clearTimeout(this.internal.htmlDlyCmdId),c.pause(),this.androidFix.setMedia)this.androidFix.pause=!0,this.androidFix.time=a;else if(!isNaN(a))try{if(c.seekable&&!("object"==typeof c.seekable&&c.seekable.length>0))throw 1;c.currentTime=a}catch(d){return void(this.internal.htmlDlyCmdId=setTimeout(function(){b.pause(a)},250))}a>0&&this._html_checkWaitForPlay()},_html_playHead:function(a){var b=this,c=this.htmlElement.media;this._html_load();try{if("object"==typeof c.seekable&&c.seekable.length>0)c.currentTime=a*c.seekable.end(c.seekable.length-1)/100;else{if(!(c.duration>0)||isNaN(c.duration))throw"e";c.currentTime=a*c.duration/100}}catch(d){return void(this.internal.htmlDlyCmdId=setTimeout(function(){b.playHead(a)},250))}this.status.waitForLoad||this._html_checkWaitForPlay()},_html_checkWaitForPlay:function(){this.status.waitForPlay&&(this.status.waitForPlay=!1,this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide(),this.status.video&&(this.internal.poster.jq.hide(),this.internal.video.jq.css({width:this.status.width,height:this.status.height})))},_html_setProperty:function(a,b){this.html.audio.available&&(this.htmlElement.audio[a]=b),this.html.video.available&&(this.htmlElement.video[a]=b)},_aurora_setAudio:function(b){var c=this;a.each(this.formats,function(a,d){return c.aurora.support[d]&&b[d]?(c.status.src=b[d],c.status.format[d]=!0,c.status.formatType=d,!1):void 0}),this.aurora.player=new AV.Player.fromURL(this.status.src),this._addAuroraEventListeners(this.aurora.player,this.aurora),"auto"===this.options.preload&&(this._aurora_load(),this.status.waitForLoad=!1)},_aurora_resetMedia:function(){this.aurora.player&&this.aurora.player.stop()},_aurora_clearMedia:function(){},_aurora_load:function(){this.status.waitForLoad&&(this.status.waitForLoad=!1,this.aurora.player.preload())},_aurora_play:function(b){this.status.waitForLoad||isNaN(b)||this.aurora.player.seek(b),this.aurora.player.playing||this.aurora.player.play(),this.status.waitForLoad=!1,this._aurora_checkWaitForPlay(),this._updateButtons(!0),this._trigger(a.jPlayer.event.play)},_aurora_pause:function(b){isNaN(b)||this.aurora.player.seek(1e3*b),this.aurora.player.pause(),b>0&&this._aurora_checkWaitForPlay(),this._updateButtons(!1),this._trigger(a.jPlayer.event.pause)},_aurora_playHead:function(a){this.aurora.player.duration>0&&this.aurora.player.seek(a*this.aurora.player.duration/100),this.status.waitForLoad||this._aurora_checkWaitForPlay()},_aurora_checkWaitForPlay:function(){this.status.waitForPlay&&(this.status.waitForPlay=!1)},_aurora_volume:function(a){this.aurora.player.volume=100*a},_aurora_mute:function(a){a?(this.aurora.properties.lastvolume=this.aurora.player.volume,this.aurora.player.volume=0):this.aurora.player.volume=this.aurora.properties.lastvolume,this.aurora.properties.muted=a},_flash_setAudio:function(b){var c=this;try{a.each(this.formats,function(a,d){if(c.flash.support[d]&&b[d]){switch(d){case"m4a":case"fla":c._getMovie().fl_setAudio_m4a(b[d]);break;case"mp3":c._getMovie().fl_setAudio_mp3(b[d]);break;case"rtmpa":c._getMovie().fl_setAudio_rtmp(b[d])}return c.status.src=b[d],c.status.format[d]=!0,c.status.formatType=d,!1}}),"auto"===this.options.preload&&(this._flash_load(),this.status.waitForLoad=!1)}catch(d){this._flashError(d)}},_flash_setVideo:function(b){var c=this;try{a.each(this.formats,function(a,d){if(c.flash.support[d]&&b[d]){switch(d){case"m4v":case"flv":c._getMovie().fl_setVideo_m4v(b[d]);break;case"rtmpv":c._getMovie().fl_setVideo_rtmp(b[d])}return c.status.src=b[d],c.status.format[d]=!0,c.status.formatType=d,!1}}),"auto"===this.options.preload&&(this._flash_load(),this.status.waitForLoad=!1)}catch(d){this._flashError(d)}},_flash_resetMedia:function(){this.internal.flash.jq.css({width:"0px",height:"0px"}),this._flash_pause(0/0)},_flash_clearMedia:function(){try{this._getMovie().fl_clearMedia()}catch(a){this._flashError(a)}},_flash_load:function(){try{this._getMovie().fl_load()}catch(a){this._flashError(a)}this.status.waitForLoad=!1},_flash_play:function(a){try{this._getMovie().fl_play(a)}catch(b){this._flashError(b)}this.status.waitForLoad=!1,this._flash_checkWaitForPlay()},_flash_pause:function(a){try{this._getMovie().fl_pause(a)}catch(b){this._flashError(b)}a>0&&(this.status.waitForLoad=!1,this._flash_checkWaitForPlay())},_flash_playHead:function(a){try{this._getMovie().fl_play_head(a)}catch(b){this._flashError(b)}this.status.waitForLoad||this._flash_checkWaitForPlay()},_flash_checkWaitForPlay:function(){this.status.waitForPlay&&(this.status.waitForPlay=!1,this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide(),this.status.video&&(this.internal.poster.jq.hide(),this.internal.flash.jq.css({width:this.status.width,height:this.status.height})))},_flash_volume:function(a){try{this._getMovie().fl_volume(a)}catch(b){this._flashError(b)}},_flash_mute:function(a){try{this._getMovie().fl_mute(a)}catch(b){this._flashError(b)}},_getMovie:function(){return document[this.internal.flash.id]},_getFlashPluginVersion:function(){var a,b=0;if(window.ActiveXObject)try{if(a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")){var c=a.GetVariable("$version");c&&(c=c.split(" ")[1].split(","),b=parseInt(c[0],10)+"."+parseInt(c[1],10))}}catch(d){}else navigator.plugins&&navigator.mimeTypes.length>0&&(a=navigator.plugins["Shockwave Flash"],a&&(b=navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/,"$1")));return 1*b},_checkForFlash:function(a){var b=!1;return this._getFlashPluginVersion()>=a&&(b=!0),b},_validString:function(a){return a&&"string"==typeof a},_limitValue:function(a,b,c){return b>a?b:a>c?c:a},_urlNotSetError:function(b){this._error({type:a.jPlayer.error.URL_NOT_SET,context:b,message:a.jPlayer.errorMsg.URL_NOT_SET,hint:a.jPlayer.errorHint.URL_NOT_SET})},_flashError:function(b){var c;c=this.internal.ready?"FLASH_DISABLED":"FLASH",this._error({type:a.jPlayer.error[c],context:this.internal.flash.swf,message:a.jPlayer.errorMsg[c]+b.message,hint:a.jPlayer.errorHint[c]}),this.internal.flash.jq.css({width:"1px",height:"1px"})},_error:function(b){this._trigger(a.jPlayer.event.error,b),this.options.errorAlerts&&this._alert("Error!"+(b.message?"\n"+b.message:"")+(b.hint?"\n"+b.hint:"")+"\nContext: "+b.context)},_warning:function(c){this._trigger(a.jPlayer.event.warning,b,c),this.options.warningAlerts&&this._alert("Warning!"+(c.message?"\n"+c.message:"")+(c.hint?"\n"+c.hint:"")+"\nContext: "+c.context)},_alert:function(a){var b="jPlayer "+this.version.script+" : id='"+this.internal.self.id+"' : "+a;this.options.consoleAlerts?window.console&&window.console.log&&window.console.log(b):alert(b)},_emulateHtmlBridge:function(){var b=this;a.each(a.jPlayer.emulateMethods.split(/\s+/g),function(a,c){b.internal.domNode[c]=function(a){b[c](a)}}),a.each(a.jPlayer.event,function(c,d){var e=!0;a.each(a.jPlayer.reservedEvent.split(/\s+/g),function(a,b){return b===c?(e=!1,!1):void 0}),e&&b.element.bind(d+".jPlayer.jPlayerHtml",function(){b._emulateHtmlUpdate();var a=document.createEvent("Event");a.initEvent(c,!1,!0),b.internal.domNode.dispatchEvent(a)})})},_emulateHtmlUpdate:function(){var b=this;a.each(a.jPlayer.emulateStatus.split(/\s+/g),function(a,c){b.internal.domNode[c]=b.status[c]}),a.each(a.jPlayer.emulateOptions.split(/\s+/g),function(a,c){b.internal.domNode[c]=b.options[c]})},_destroyHtmlBridge:function(){var b=this;this.element.unbind(".jPlayerHtml");var c=a.jPlayer.emulateMethods+" "+a.jPlayer.emulateStatus+" "+a.jPlayer.emulateOptions;a.each(c.split(/\s+/g),function(a,c){delete b.internal.domNode[c]})}},a.jPlayer.error={FLASH:"e_flash",FLASH_DISABLED:"e_flash_disabled",NO_SOLUTION:"e_no_solution",NO_SUPPORT:"e_no_support",URL:"e_url",URL_NOT_SET:"e_url_not_set",VERSION:"e_version"},a.jPlayer.errorMsg={FLASH:"jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ",FLASH_DISABLED:"jPlayer's Flash fallback has been disabled by the browser due to the CSS rules you have used. Details: ",NO_SOLUTION:"No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.",NO_SUPPORT:"It is not possible to play any media format provided in setMedia() on this browser using your current options.",URL:"Media URL could not be loaded.",URL_NOT_SET:"Attempt to issue media playback commands, while no media url is set.",VERSION:"jPlayer "+a.jPlayer.prototype.version.script+" needs Jplayer.swf version "+a.jPlayer.prototype.version.needFlash+" but found "},a.jPlayer.errorHint={FLASH:"Check your swfPath option and that Jplayer.swf is there.",FLASH_DISABLED:"Check that you have not display:none; the jPlayer entity or any ancestor.",NO_SOLUTION:"Review the jPlayer options: support and supplied.",NO_SUPPORT:"Video or audio formats defined in the supplied option are missing.",URL:"Check media URL is valid.",URL_NOT_SET:"Use setMedia() to set the media URL.",VERSION:"Update jPlayer files."},a.jPlayer.warning={CSS_SELECTOR_COUNT:"e_css_selector_count",CSS_SELECTOR_METHOD:"e_css_selector_method",CSS_SELECTOR_STRING:"e_css_selector_string",OPTION_KEY:"e_option_key"},a.jPlayer.warningMsg={CSS_SELECTOR_COUNT:"The number of css selectors found did not equal one: ",CSS_SELECTOR_METHOD:"The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",CSS_SELECTOR_STRING:"The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",OPTION_KEY:"The option requested in jPlayer('option') is undefined."},a.jPlayer.warningHint={CSS_SELECTOR_COUNT:"Check your css selector and the ancestor.",CSS_SELECTOR_METHOD:"Check your method name.",CSS_SELECTOR_STRING:"Check your css selector is a string.",OPTION_KEY:"Check your option name."}}); \ No newline at end of file diff --git a/app/assets/javascripts/video_pro/jquery.jplayer.swf b/app/assets/javascripts/video_pro/jquery.jplayer.swf new file mode 100644 index 0000000..340f7f9 Binary files /dev/null and b/app/assets/javascripts/video_pro/jquery.jplayer.swf differ diff --git a/app/assets/javascripts/video_pro/popcorn.jplayer.js b/app/assets/javascripts/video_pro/popcorn.jplayer.js new file mode 100644 index 0000000..8eff0da --- /dev/null +++ b/app/assets/javascripts/video_pro/popcorn.jplayer.js @@ -0,0 +1,579 @@ +/* + * jPlayer Player Plugin for Popcorn JavaScript Library + * http://www.jplayer.org + * + * Copyright (c) 2012 - 2014 Happyworm Ltd + * Licensed under the MIT license. + * http://opensource.org/licenses/MIT + * + * Author: Mark J Panaghiston + * Version: 1.1.6 + * Date: 27th November 2014 + * + * For Popcorn Version: 1.3 + * For jPlayer Version: 2.9.0 + * Requires: jQuery 1.7+ + * Note: jQuery dependancy cannot be removed since jPlayer 2 is a jQuery plugin. Use of jQuery will be kept to a minimum. + */ + +(function(Popcorn) { + + var JQUERY_SCRIPT = '//code.jquery.com/jquery-1.11.1.min.js', // Used if jQuery not already present. + JPLAYER_SCRIPT = '//code.jplayer.org/2.9.0/jplayer/jquery.jplayer.min.js', // Used if jPlayer not already present. + JPLAYER_SWFPATH = '//code.jplayer.org/2.9.0/jplayer/jquery.jplayer.swf', // Used if not specified in jPlayer options via SRC Object. + SOLUTION = 'html,flash', // The default solution option. + DEBUG = false, // Decided to leave the debugging option and console output in for the time being. Overhead is trivial. + jQueryDownloading = false, // Flag to stop multiple instances from each pulling in jQuery, thus corrupting it. + jPlayerDownloading = false, // Flag to stop multiple instances from each pulling in jPlayer, thus corrupting it. + format = { // Duplicate of jPlayer 2.5.0 object, to avoid always requiring jQuery and jPlayer to be loaded before performing the _canPlayType() test. + mp3: { + codec: 'audio/mpeg', + flashCanPlay: true, + media: 'audio' + }, + m4a: { // AAC / MP4 + codec: 'audio/mp4; codecs="mp4a.40.2"', + flashCanPlay: true, + media: 'audio' + }, + m3u8a: { // AAC / MP4 / Apple HLS + codec: 'application/vnd.apple.mpegurl; codecs="mp4a.40.2"', + flashCanPlay: false, + media: 'audio' + }, + m3ua: { // M3U + codec: 'audio/mpegurl', + flashCanPlay: false, + media: 'audio' + }, + oga: { // OGG + codec: 'audio/ogg; codecs="vorbis, opus"', + flashCanPlay: false, + media: 'audio' + }, + flac: { // FLAC + codec: 'audio/x-flac', + flashCanPlay: false, + media: 'audio' + }, + wav: { // PCM + codec: 'audio/wav; codecs="1"', + flashCanPlay: false, + media: 'audio' + }, + webma: { // WEBM + codec: 'audio/webm; codecs="vorbis"', + flashCanPlay: false, + media: 'audio' + }, + fla: { // FLV / F4A + codec: 'audio/x-flv', + flashCanPlay: true, + media: 'audio' + }, + rtmpa: { // RTMP AUDIO + codec: 'audio/rtmp; codecs="rtmp"', + flashCanPlay: true, + media: 'audio' + }, + m4v: { // H.264 / MP4 + codec: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', + flashCanPlay: true, + media: 'video' + }, + m3u8v: { // H.264 / AAC / MP4 / Apple HLS + codec: 'application/vnd.apple.mpegurl; codecs="avc1.42E01E, mp4a.40.2"', + flashCanPlay: false, + media: 'video' + }, + m3uv: { // M3U + codec: 'audio/mpegurl', + flashCanPlay: false, + media: 'video' + }, + ogv: { // OGG + codec: 'video/ogg; codecs="theora, vorbis"', + flashCanPlay: false, + media: 'video' + }, + webmv: { // WEBM + codec: 'video/webm; codecs="vorbis, vp8"', + flashCanPlay: false, + media: 'video' + }, + flv: { // FLV / F4V + codec: 'video/x-flv', + flashCanPlay: true, + media: 'video' + }, + rtmpv: { // RTMP VIDEO + codec: 'video/rtmp; codecs="rtmp"', + flashCanPlay: true, + media: 'video' + } + }, + isObject = function(val) { // Basic check for Object + if(val && typeof val === 'object' && val.hasOwnProperty) { + return true; + } else { + return false; + } + }, + getMediaType = function(url) { // Function to gleam the media type from the URL + var mediaType = false; + if(/\.mp3$/i.test(url)) { + mediaType = 'mp3'; + } else if(/\.mp4$/i.test(url) || /\.m4v$/i.test(url)) { + mediaType = 'm4v'; + } else if(/\.m4a$/i.test(url)) { + mediaType = 'm4a'; + } else if(/\.ogg$/i.test(url) || /\.oga$/i.test(url)) { + mediaType = 'oga'; + } else if(/\.ogv$/i.test(url)) { + mediaType = 'ogv'; + } else if(/\.webm$/i.test(url)) { + mediaType = 'webmv'; + } + return mediaType; + }, + getSupplied = function(url) { // Function to generate a supplied option from an src object. ie., When supplied not specified. + var supplied = '', + separator = ''; + if(isObject(url)) { + // Generate supplied option from object's properties. Non-format properties would be ignored by jPlayer. Order is unpredictable. + for(var prop in url) { + if(url.hasOwnProperty(prop)) { + supplied += separator + prop; + separator = ','; + } + } + } + if(DEBUG) console.log('getSupplied(): Generated: supplied = "' + supplied + '"'); + return supplied; + }; + + Popcorn.player( 'jplayer', { + _canPlayType: function( containerType, url ) { + // url : Either a String or an Object structured similar a jPlayer media object. ie., As used by setMedia in jPlayer. + // The url object may also contain a solution and supplied property. + + // Define the src object structure here! + + var cType = containerType.toLowerCase(), + srcObj = { + media:{}, + options:{} + }, + rVal = false, // Only a boolean false means it is not supported. + mediaType; + + if(cType !== 'video' && cType !== 'audio') { + + if(typeof url === 'string') { + // Check it starts with http, so the URL is absolute... Well, it is not a perfect check. + if(/^http.*/i.test(url)) { + mediaType = getMediaType(url); + if(mediaType) { + srcObj.media[mediaType] = url; + srcObj.options.solution = SOLUTION; + srcObj.options.supplied = mediaType; + } + } + } else { + srcObj = url; // Assume the url is an src object. + } + + // Check for Object and appropriate minimum data structure. + if(isObject(srcObj) && isObject(srcObj.media)) { + + if(!isObject(srcObj.options)) { + srcObj.options = {}; + } + + if(!srcObj.options.solution) { + srcObj.options.solution = SOLUTION; + } + + if(!srcObj.options.supplied) { + srcObj.options.supplied = getSupplied(srcObj.media); + } + + // Figure out how jPlayer will play it. + // This may not work properly when both audio and video is supplied. ie., A media player. But it should return truethy and jPlayer can figure it out. + + var solution = srcObj.options.solution.toLowerCase().split(","), // Create the solution array, with prority based on the order of the solution string. + supplied = srcObj.options.supplied.toLowerCase().split(","); // Create the supplied formats array, with prority based on the order of the supplied formats string. + + for(var sol = 0; sol < solution.length; sol++) { + + var solutionType = solution[sol].replace(/^\s+|\s+$/g, ""), //trim + checkingHtml = solutionType === 'html', + checkingFlash = solutionType === 'flash', + mediaElem; + + for(var fmt = 0; fmt < supplied.length; fmt++) { + mediaType = supplied[fmt].replace(/^\s+|\s+$/g, ""); //trim + if(format[mediaType]) { // Check format is valid. + + // Create an HTML5 media element for the type of media. + if(!mediaElem && checkingHtml) { + mediaElem = document.createElement(format[mediaType].media); + } + // See if the HTML5 media element can play the MIME / Codec type. + // Flash also returns the object if the format is playable, so it is truethy, but that html property is false. + // This assumes Flash is available, but that should be dealt with by jPlayer if that happens. + var htmlCanPlay = !!(mediaElem && mediaElem.canPlayType && mediaElem.canPlayType(format[mediaType].codec)), + htmlWillPlay = htmlCanPlay && checkingHtml, + flashWillPlay = format[mediaType].flashCanPlay && checkingFlash; + // The first one found will match what jPlayer uses. + if(htmlWillPlay || flashWillPlay) { + rVal = { + html: htmlWillPlay, + type: mediaType + }; + sol = solution.length; // Exit solution loop + fmt = supplied.length; // Exit supplied loop + } + } + } + } + } + } + return rVal; + }, + // _setup: function( options ) { // Warning: options is deprecated. + _setup: function() { + var media = this, + myPlayer, // The jQuery selector of the jPlayer element. Usually a
    + jPlayerObj, // The jPlayer data instance. For performance and DRY code. + mediaType = 'unknown', + jpMedia = {}, + jpOptions = {}, + ready = false, // Used during init to override the annoying duration dependance in the track event padding during Popcorn's isReady(). ie., We is ready after loadeddata and duration can then be set real value at leisure. + duration = 0, // For the durationchange event with both HTML5 and Flash solutions. Used with 'ready' to keep control during the Popcorn isReady() via loadeddata event. (Duration=0 is bad.) + durationchangeId = null, // A timeout ID used with delayed durationchange event. (Because of the duration=NaN fudge to avoid Popcorn track event corruption.) + canplaythrough = false, + error = null, // The MediaError object. + + dispatchDurationChange = function() { + if(ready) { + if(DEBUG) console.log('Dispatched event : durationchange : ' + duration); + media.dispatchEvent('durationchange'); + } else { + if(DEBUG) console.log('DELAYED EVENT (!ready) : durationchange : ' + duration); + clearTimeout(durationchangeId); // Stop multiple triggers causing multiple timeouts running in parallel. + durationchangeId = setTimeout(dispatchDurationChange, 250); + } + }, + + jPlayerFlashEventsPatch = function() { + + /* Events already supported by jPlayer Flash: + * loadstart + * loadedmetadata (M4A, M4V) + * progress + * play + * pause + * seeking + * seeked + * timeupdate + * ended + * volumechange + * error <- See the custom handler in jPlayerInit() + */ + + /* Events patched: + * loadeddata + * durationchange + * canplaythrough + * playing + */ + + /* Events NOT patched: + * suspend + * abort + * emptied + * stalled + * loadedmetadata (MP3) + * waiting + * canplay + * ratechange + */ + + // Triggering patched events through the jPlayer Object so the events are homogeneous. ie., The contain the event.jPlayer data structure. + + var checkDuration = function(event) { + if(event.jPlayer.status.duration !== duration) { + duration = event.jPlayer.status.duration; + dispatchDurationChange(); + } + }, + + checkCanPlayThrough = function(event) { + if(!canplaythrough && event.jPlayer.status.seekPercent === 100) { + canplaythrough = true; + setTimeout(function() { + if(DEBUG) console.log('Trigger : canplaythrough'); + jPlayerObj._trigger($.jPlayer.event.canplaythrough); + }, 0); + } + }; + + myPlayer.bind($.jPlayer.event.loadstart, function() { + setTimeout(function() { + if(DEBUG) console.log('Trigger : loadeddata'); + jPlayerObj._trigger($.jPlayer.event.loadeddata); + }, 0); + }) + .bind($.jPlayer.event.progress, function(event) { + checkDuration(event); + checkCanPlayThrough(event); + }) + .bind($.jPlayer.event.timeupdate, function(event) { + checkDuration(event); + checkCanPlayThrough(event); + }) + .bind($.jPlayer.event.play, function() { + setTimeout(function() { + if(DEBUG) console.log('Trigger : playing'); + jPlayerObj._trigger($.jPlayer.event.playing); + }, 0); + }); + + if(DEBUG) console.log('Created CUSTOM event handlers for FLASH'); + }, + + jPlayerInit = function() { + (function($) { + + myPlayer = $('#' + media.id); + + if(typeof media.src === 'string') { + mediaType = getMediaType(media.src); + jpMedia[mediaType] = media.src; + jpOptions.supplied = mediaType; + jpOptions.solution = SOLUTION; + } else if(isObject(media.src)) { + jpMedia = isObject(media.src.media) ? media.src.media : {}; + jpOptions = isObject(media.src.options) ? media.src.options : {}; + jpOptions.solution = jpOptions.solution || SOLUTION; + jpOptions.supplied = jpOptions.supplied || getSupplied(media.src.media); + } + + // Allow the swfPath to be set to local server. ie., If the jPlayer Plugin is local and already on the page, then you can also use the local SWF. + jpOptions.swfPath = jpOptions.swfPath || JPLAYER_SWFPATH; + + myPlayer.bind($.jPlayer.event.ready, function(event) { + if(event.jPlayer.flash.used) { + jPlayerFlashEventsPatch(); + } + // Set the media andd load it, so that the Flash solution behaves similar to HTML5 solution. + // This also allows the loadstart event to be used to know jPlayer is ready. + $(this).jPlayer('setMedia', jpMedia).jPlayer('load'); + }); + + // Do not auto-bubble the reserved events, nor the loadeddata and durationchange event, since the duration must be carefully handled when loadeddata event occurs. + // See the duration property code for more details. (Ranting.) + + var reservedEvents = $.jPlayer.reservedEvent + ' loadeddata durationchange', + reservedEvent = reservedEvents.split(/\s+/g); + + // Generate event handlers for all the standard HTML5 media events. (Except durationchange) + + var bindEvent = function(name) { + myPlayer.bind($.jPlayer.event[name], function(event) { + if(DEBUG) console.log('Dispatched event: ' + name + (event && event.jPlayer ? ' (' + event.jPlayer.status.currentTime + 's)' : '')); // Must be after dispatch for some reason on Firefox/Opera + media.dispatchEvent(name); + }); + if(DEBUG) console.log('Created event handler for: ' + name); + }; + + for(var eventName in $.jPlayer.event) { + if($.jPlayer.event.hasOwnProperty(eventName)) { + var nativeEvent = true; + for(var iRes in reservedEvent) { + if(reservedEvent.hasOwnProperty(iRes)) { + if(reservedEvent[iRes] === eventName) { + nativeEvent = false; + break; + } + } + } + if(nativeEvent) { + bindEvent(eventName); + } else { + if(DEBUG) console.log('Skipped auto event handler creation for: ' + eventName); + } + } + } + + myPlayer.bind($.jPlayer.event.loadeddata, function(event) { + if(DEBUG) console.log('Dispatched event: loadeddata' + (event && event.jPlayer ? ' (' + event.jPlayer.status.currentTime + 's)' : '')); + media.dispatchEvent('loadeddata'); + ready = true; + }); + if(DEBUG) console.log('Created CUSTOM event handler for: loadeddata'); + + myPlayer.bind($.jPlayer.event.durationchange, function(event) { + duration = event.jPlayer.status.duration; + dispatchDurationChange(); + }); + if(DEBUG) console.log('Created CUSTOM event handler for: durationchange'); + + // The error event is a special case. Plus jPlayer error event assumes it is a broken URL. (It could also be a decoder error... Or aborted or a Network error.) + myPlayer.bind($.jPlayer.event.error, function(event) { + // Not sure how to handle the error situation. Popcorn does not appear to have the error or error.code property documented here: http://popcornjs.org/popcorn-docs/media-methods/ + // If any error event happens, then something has gone pear shaped. + + error = event.jPlayer.error; // Saving object pointer, not a copy of the object. Possible garbage collection issue... But the player is dead anyway, so don't care. + + if(error.type === $.jPlayer.error.URL) { + error.code = 4; // MEDIA_ERR_SRC_NOT_SUPPORTED since jPlayer makes this assumption. It is the most common error, then the decode error. Never seen either of the other 2 error types occur. + } else { + error.code = 0; // It was a jPlayer error, not an HTML5 media error. + } + + if(DEBUG) console.log('Dispatched event: error'); + if(DEBUG) console.dir(error); + media.dispatchEvent('error'); + }); + if(DEBUG) console.log('Created CUSTOM event handler for: error'); + + Popcorn.player.defineProperty( media, 'error', { + set: function() { + // Read-only property + return error; + }, + get: function() { + return error; + } + }); + + Popcorn.player.defineProperty( media, 'currentTime', { + set: function( val ) { + if(jPlayerObj.status.paused) { + myPlayer.jPlayer('pause', val); + } else { + myPlayer.jPlayer('play', val); + } + return val; + }, + get: function() { + return jPlayerObj.status.currentTime; + } + }); + + /* The joy of duration and the loadeddata event isReady() handler + * The duration is assumed to be a NaN or a valid duration. + * jPlayer uses zero instead of a NaN and this screws up the Popcorn track event start/end arrays padding. + * This line here: + * videoDurationPlus = duration != duration ? Number.MAX_VALUE : duration + 1; + * Not sure why it is not simply: + * videoDurationPlus = Number.MAX_VALUE; // Who cares if the padding is close to the real duration? + * So if you trigger loadeddata before the duration is correct, the track event padding is screwed up. (It pads the start, not the end... Well, duration+1 = 0+1 = 1s) + * That line makes the MP3 Flash fallback difficult to setup. The whole MP3 will need to load before the duration is known. + * Planning on using a NaN for duration until a >0 value is found... Except with MP3, where seekPercent must be 100% before setting the duration. + * Why not just use a NaN during init... And then correct the duration later? + */ + + Popcorn.player.defineProperty( media, 'duration', { + set: function() { + // Read-only property + if(ready) { + return duration; + } else { + return NaN; + } + }, + get: function() { + if(ready) { + return duration; // Popcorn has initialized, we can now use duration zero or whatever without fear. + } else { + return NaN; // Keep the duration a NaN until after loadeddata event has occurred. Otherwise Popcorn track event padding is corrupted. + } + } + }); + + Popcorn.player.defineProperty( media, 'muted', { + set: function( val ) { + myPlayer.jPlayer('mute', val); + return jPlayerObj.options.muted; + }, + get: function() { + return jPlayerObj.options.muted; + } + }); + + Popcorn.player.defineProperty( media, 'volume', { + set: function( val ) { + myPlayer.jPlayer('volume', val); + return jPlayerObj.options.volume; + }, + get: function() { + return jPlayerObj.options.volume; + } + }); + + Popcorn.player.defineProperty( media, 'paused', { + set: function() { + // Read-only property + return jPlayerObj.status.paused; + }, + get: function() { + return jPlayerObj.status.paused; + } + }); + + media.play = function() { + myPlayer.jPlayer('play'); + }; + media.pause = function() { + myPlayer.jPlayer('pause'); + }; + + myPlayer.jPlayer(jpOptions); // Instance jPlayer. Note that the options should not have a ready event defined... Kill it by default? + jPlayerObj = myPlayer.data('jPlayer'); + + }(jQuery)); + }, + + jPlayerCheck = function() { + if (!jQuery.jPlayer) { + if (!jPlayerDownloading) { + jPlayerDownloading = true; + Popcorn.getScript(JPLAYER_SCRIPT, function() { + jPlayerDownloading = false; + jPlayerInit(); + }); + } else { + setTimeout(jPlayerCheck, 250); + } + } else { + jPlayerInit(); + } + }, + + jQueryCheck = function() { + if (!window.jQuery) { + if (!jQueryDownloading) { + jQueryDownloading = true; + Popcorn.getScript(JQUERY_SCRIPT, function() { + jQueryDownloading = false; + jPlayerCheck(); + }); + } else { + setTimeout(jQueryCheck, 250); + } + } else { + jPlayerCheck(); + } + }; + + jQueryCheck(); + }, + _teardown: function() { + jQuery('#' + this.id).jPlayer('destroy'); + } + }); + +}(Popcorn)); \ No newline at end of file diff --git a/app/assets/javascripts/video_pro/popcorn.jplayer.min.js b/app/assets/javascripts/video_pro/popcorn.jplayer.min.js new file mode 100644 index 0000000..9b69a13 --- /dev/null +++ b/app/assets/javascripts/video_pro/popcorn.jplayer.min.js @@ -0,0 +1,2 @@ +/*! Popcorn Player for jPlayer 2.9.2 ~ (c) 2009-2014 Happyworm Ltd ~ MIT License */ +!function(a){var b="//code.jquery.com/jquery-1.11.1.min.js",c="//code.jplayer.org/2.9.0/jplayer/jquery.jplayer.min.js",d="//code.jplayer.org/2.9.0/jplayer/jquery.jplayer.swf",e="html,flash",f=!1,g=!1,h=!1,i={mp3:{codec:"audio/mpeg",flashCanPlay:!0,media:"audio"},m4a:{codec:'audio/mp4; codecs="mp4a.40.2"',flashCanPlay:!0,media:"audio"},m3u8a:{codec:'application/vnd.apple.mpegurl; codecs="mp4a.40.2"',flashCanPlay:!1,media:"audio"},m3ua:{codec:"audio/mpegurl",flashCanPlay:!1,media:"audio"},oga:{codec:'audio/ogg; codecs="vorbis, opus"',flashCanPlay:!1,media:"audio"},flac:{codec:"audio/x-flac",flashCanPlay:!1,media:"audio"},wav:{codec:'audio/wav; codecs="1"',flashCanPlay:!1,media:"audio"},webma:{codec:'audio/webm; codecs="vorbis"',flashCanPlay:!1,media:"audio"},fla:{codec:"audio/x-flv",flashCanPlay:!0,media:"audio"},rtmpa:{codec:'audio/rtmp; codecs="rtmp"',flashCanPlay:!0,media:"audio"},m4v:{codec:'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',flashCanPlay:!0,media:"video"},m3u8v:{codec:'application/vnd.apple.mpegurl; codecs="avc1.42E01E, mp4a.40.2"',flashCanPlay:!1,media:"video"},m3uv:{codec:"audio/mpegurl",flashCanPlay:!1,media:"video"},ogv:{codec:'video/ogg; codecs="theora, vorbis"',flashCanPlay:!1,media:"video"},webmv:{codec:'video/webm; codecs="vorbis, vp8"',flashCanPlay:!1,media:"video"},flv:{codec:"video/x-flv",flashCanPlay:!0,media:"video"},rtmpv:{codec:'video/rtmp; codecs="rtmp"',flashCanPlay:!0,media:"video"}},j=function(a){return a&&"object"==typeof a&&a.hasOwnProperty?!0:!1},k=function(a){var b=!1;return/\.mp3$/i.test(a)?b="mp3":/\.mp4$/i.test(a)||/\.m4v$/i.test(a)?b="m4v":/\.m4a$/i.test(a)?b="m4a":/\.ogg$/i.test(a)||/\.oga$/i.test(a)?b="oga":/\.ogv$/i.test(a)?b="ogv":/\.webm$/i.test(a)&&(b="webmv"),b},l=function(a){var b="",c="";if(j(a))for(var d in a)a.hasOwnProperty(d)&&(b+=c+d,c=",");return f&&console.log('getSupplied(): Generated: supplied = "'+b+'"'),b};a.player("jplayer",{_canPlayType:function(a,b){var c,d=a.toLowerCase(),f={media:{},options:{}},g=!1;if("video"!==d&&"audio"!==d&&("string"==typeof b?/^http.*/i.test(b)&&(c=k(b),c&&(f.media[c]=b,f.options.solution=e,f.options.supplied=c)):f=b,j(f)&&j(f.media))){j(f.options)||(f.options={}),f.options.solution||(f.options.solution=e),f.options.supplied||(f.options.supplied=l(f.media));for(var h=f.options.solution.toLowerCase().split(","),m=f.options.supplied.toLowerCase().split(","),n=0;n 500) { + var resize = 500/video_dataW + video_dataW = Math.floor(video_dataW*resize); + video_dataH = Math.floor(video_dataH*resize); + console.log(video_dataW) + }; + if(video_dataH > 300) { + var resize = 300/video_dataH + video_dataW = Math.floor(video_dataW*resize); + video_dataH = Math.floor(video_dataH*resize); + } + slideshow($(this).find('.preview'), video_dataEffect, video_dataTime, video_dataSpeed); + $(this).find('.preview').css({ + 'width': video_dataW, + 'height': video_dataH + }); + $(this).find('.preview img').css({ + 'width': '100%', + 'height': '100%' + }); + }); + $('#preview').on('hidden', function() { + $(this).attr('aria-labelledby', '').find('h3').text('') + $(this).find('.preview').cycle('destroy'); + $(this).find('.preview img').removeAttr('style'); + }); +}; + +$(function() { + var video_dataName = null, + video_dataEffect = null, + video_dataTime = null, + video_dataSpeed = null, + video_dataW = null, + video_dataH = null, + $preview = $('.main-forms .preview'); + + $(".video_pro_ad_fx").change(function () { + var suckIE = false; + // video_dataTime = $("#pageslide #timeout").val()*1000; + // video_dataSpeed = $("#pageslide #speed").val()*1000; + + video_dataTime = parseInt(video_dataTime) || 300; + video_dataSpeed = parseInt(video_dataSpeed) || 300; + slideshow($preview, $(this).val(), 2000, 1000); + }); + preview(); +}); + diff --git a/app/assets/stylesheets/admin/video_images.css b/app/assets/stylesheets/admin/video_images.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/admin/video_images.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/assets/stylesheets/admin/video_pros.css b/app/assets/stylesheets/admin/video_pros.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/admin/video_pros.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/assets/stylesheets/video_pro/.keep b/app/assets/stylesheets/video_pro/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/video_pro/jplayer.blue.monday.css b/app/assets/stylesheets/video_pro/jplayer.blue.monday.css new file mode 100644 index 0000000..75e0c44 --- /dev/null +++ b/app/assets/stylesheets/video_pro/jplayer.blue.monday.css @@ -0,0 +1,555 @@ +/*! Blue Monday Skin for jPlayer 2.9.2 ~ (c) 2009-2014 Happyworm Ltd ~ MIT License */ + +/* + * Skin for jPlayer Plugin (jQuery JavaScript Library) + * http://www.jplayer.org + * + * Skin Name: Blue Monday + * + * Copyright (c) 2010 - 2014 Happyworm Ltd + * Licensed under the MIT license. + * - http://www.opensource.org/licenses/mit-license.php + * + * Author: Silvia Benvenuti + * Skin Version: 5.1 (jPlayer 2.8.0) + * Date: 13th November 2014 + */ +.jp-audio *:focus, +.jp-audio-stream *:focus, +.jp-video *:focus { + /* Disable the browser focus highlighting. */ + outline: none; } + +.jp-audio button::-moz-focus-inner, +.jp-audio-stream button::-moz-focus-inner, +.jp-video button::-moz-focus-inner { + /* Disable the browser CSS3 focus highlighting. */ + border: 0; } + +.jp-audio, +.jp-audio-stream, +.jp-video { + font-size: 1em; + font-family: Verdana, Arial, sans-serif; + line-height: 1.6; + color: #666; + border: 1px solid #009be3; + background-color: #eee; } + +.jp-audio { + width: 420px; } + +.jp-audio-stream { + width: 182px; } + +.jp-video-270p { + width: 480px; } + +.jp-video-360p { + width: 640px; } + +.jp-video-full { + /* Rules for IE6 (full-screen) */ + width: 480px; + height: 270px; + /* Rules for IE7 (full-screen) - Otherwise the relative container causes other page items that are not position:static (default) to appear over the video/gui. */ + position: static !important; + position: relative; } + +/* The z-index rule is defined in this manner to enable Popcorn plugins that add overlays to video area. EG. Subtitles. */ +.jp-video-full div div { + z-index: 1000; } + +.jp-video-full .jp-jplayer { + top: 0; + left: 0; + position: fixed !important; + position: relative; + /* Rules for IE6 (full-screen) */ + overflow: hidden; } + +.jp-video-full .jp-gui { + position: fixed !important; + position: static; + /* Rules for IE6 (full-screen) */ + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1001; + /* 1 layer above the others. */ } + +.jp-video-full .jp-interface { + position: absolute !important; + position: relative; + /* Rules for IE6 (full-screen) */ + bottom: 0; + left: 0; } + +.jp-interface { + position: relative; + background-color: #eee; + width: 100%; } + +.jp-audio .jp-interface { + height: 80px; } + +.jp-audio-stream .jp-interface { + height: 80px; } + +.jp-video .jp-interface { + border-top: 1px solid #009be3; } + +/* @group CONTROLS */ +.jp-controls-holder { + clear: both; + width: 100%; + margin: 0 auto; + position: relative; + overflow: hidden; + top: -8px; + /* This negative value depends on the size of the text in jp-currentTime and jp-duration */ } + +.jp-interface .jp-controls { + margin: 0; + padding: 0; + overflow: hidden; } + +.jp-audio .jp-controls { + width: 380px; + padding: 20px 20px 0 20px; } + +.jp-audio-stream .jp-controls { + position: absolute; + top: 20px; + left: 20px; + width: 142px; } + +.jp-video .jp-type-single .jp-controls { + width: 78px; + margin-left: 200px; } + +.jp-video .jp-type-playlist .jp-controls { + width: 134px; + margin-left: 172px; } + +.jp-video .jp-controls { + float: left; } + +.jp-controls button { + display: block; + float: left; + overflow: hidden; + text-indent: -9999px; + border: none; + cursor: pointer; } + +.jp-play { + width: 40px; + height: 40px; } + +.jp-play { + background: url("/assets/jplayer.blue.monday.jpg") 0 0 no-repeat; } + +.jp-play:focus { + background: url("/assets/jplayer.blue.monday.jpg") -41px 0 no-repeat; } + +.jp-state-playing .jp-play { + background: url("/assets/jplayer.blue.monday.jpg") 0 -42px no-repeat; } + +.jp-state-playing .jp-play:focus { + background: url("/assets/jplayer.blue.monday.jpg") -41px -42px no-repeat; } + +.jp-stop, .jp-previous, .jp-next { + width: 28px; + height: 28px; + margin-top: 6px; } + +.jp-stop { + background: url("/assets/jplayer.blue.monday.jpg") 0 -83px no-repeat; + margin-left: 10px; } + +.jp-stop:focus { + background: url("/assets/jplayer.blue.monday.jpg") -29px -83px no-repeat; } + +.jp-previous { + background: url("/assets/jplayer.blue.monday.jpg") 0 -112px no-repeat; } + +.jp-previous:focus { + background: url("/assets/jplayer.blue.monday.jpg") -29px -112px no-repeat; } + +.jp-next { + background: url("/assets/jplayer.blue.monday.jpg") 0 -141px no-repeat; } + +.jp-next:focus { + background: url("/assets/jplayer.blue.monday.jpg") -29px -141px no-repeat; } + +/* @end */ +/* @group progress bar */ +.jp-progress { + overflow: hidden; + background-color: #ddd; } + +.jp-audio .jp-progress { + position: absolute; + top: 32px; + height: 15px; } + +.jp-audio .jp-type-single .jp-progress { + left: 110px; + width: 186px; } + +.jp-audio .jp-type-playlist .jp-progress { + left: 166px; + width: 130px; } + +.jp-video .jp-progress { + top: 0px; + left: 0px; + width: 100%; + height: 10px; } + +.jp-seek-bar { + background: url("/assets/jplayer.blue.monday.jpg") 0 -202px repeat-x; + width: 0px; + height: 100%; + cursor: pointer; } + +.jp-play-bar { + background: url("/assets/jplayer.blue.monday.jpg") 0 -218px repeat-x; + width: 0px; + height: 100%; } + +/* The seeking class is added/removed inside jPlayer */ +.jp-seeking-bg { + background: url("/assets/jplayer.blue.monday.seeking.gif"); } + +/* @end */ +/* @group volume controls */ +.jp-state-no-volume .jp-volume-controls { + display: none; } + +.jp-volume-controls { + position: absolute; + top: 32px; + left: 308px; + width: 200px; } + +.jp-audio-stream .jp-volume-controls { + left: 70px; } + +.jp-video .jp-volume-controls { + top: 12px; + left: 50px; } + +.jp-volume-controls button { + display: block; + position: absolute; + overflow: hidden; + text-indent: -9999px; + border: none; + cursor: pointer; } + +.jp-mute, +.jp-volume-max { + width: 18px; + height: 15px; } + +.jp-volume-max { + left: 74px; } + +.jp-mute { + background: url("/assets/jplayer.blue.monday.jpg") 0 -170px no-repeat; } + +.jp-mute:focus { + background: url("/assets/jplayer.blue.monday.jpg") -19px -170px no-repeat; } + +.jp-state-muted .jp-mute { + background: url("/assets/jplayer.blue.monday.jpg") -60px -170px no-repeat; } + +.jp-state-muted .jp-mute:focus { + background: url("/assets/jplayer.blue.monday.jpg") -79px -170px no-repeat; } + +.jp-volume-max { + background: url("/assets/jplayer.blue.monday.jpg") 0 -186px no-repeat; } + +.jp-volume-max:focus { + background: url("/assets/jplayer.blue.monday.jpg") -19px -186px no-repeat; } + +.jp-volume-bar { + position: absolute; + overflow: hidden; + background: url("/assets/jplayer.blue.monday.jpg") 0 -250px repeat-x; + top: 5px; + left: 22px; + width: 46px; + height: 5px; + cursor: pointer; } + +.jp-volume-bar-value { + background: url("/assets/jplayer.blue.monday.jpg") 0 -256px repeat-x; + width: 0px; + height: 5px; } + +/* @end */ +/* @group current time and duration */ +.jp-audio .jp-time-holder { + position: absolute; + top: 50px; } + +.jp-audio .jp-type-single .jp-time-holder { + left: 110px; + width: 186px; } + +.jp-audio .jp-type-playlist .jp-time-holder { + left: 166px; + width: 130px; } + +.jp-current-time, +.jp-duration { + width: 60px; + font-size: .64em; + font-style: oblique; } + +.jp-current-time { + float: left; + display: inline; + cursor: default; } + +.jp-duration { + float: right; + display: inline; + text-align: right; + cursor: pointer; } + +.jp-video .jp-current-time { + margin-left: 20px; } + +.jp-video .jp-duration { + margin-right: 20px; } + +/* @end */ +/* @group playlist */ +.jp-details { + font-weight: bold; + text-align: center; + cursor: default; } + +.jp-details, +.jp-playlist { + width: 100%; + background-color: #ccc; + border-top: 1px solid #009be3; } + +.jp-type-single .jp-details, +.jp-type-playlist .jp-details { + border-top: none; } + +.jp-details .jp-title { + margin: 0; + padding: 5px 20px; + font-size: .72em; + font-weight: bold; } + +.jp-playlist ul { + list-style-type: none; + margin: 0; + padding: 0 20px; + font-size: .72em; } + +.jp-playlist li { + padding: 5px 0 4px 20px; + border-bottom: 1px solid #eee; } + +.jp-playlist li div { + display: inline; } + +/* Note that the first-child (IE6) and last-child (IE6/7/8) selectors do not work on IE */ +div.jp-type-playlist div.jp-playlist li:last-child { + padding: 5px 0 5px 20px; + border-bottom: none; } + +div.jp-type-playlist div.jp-playlist li.jp-playlist-current { + list-style-type: square; + list-style-position: inside; + padding-left: 7px; } + +div.jp-type-playlist div.jp-playlist a { + color: #333; + text-decoration: none; } + +div.jp-type-playlist div.jp-playlist a:hover { + color: #0d88c1; } + +div.jp-type-playlist div.jp-playlist a.jp-playlist-current { + color: #0d88c1; } + +div.jp-type-playlist div.jp-playlist a.jp-playlist-item-remove { + float: right; + display: inline; + text-align: right; + margin-right: 10px; + font-weight: bold; + color: #666; } + +div.jp-type-playlist div.jp-playlist a.jp-playlist-item-remove:hover { + color: #0d88c1; } + +div.jp-type-playlist div.jp-playlist span.jp-free-media { + float: right; + display: inline; + text-align: right; + margin-right: 10px; } + +div.jp-type-playlist div.jp-playlist span.jp-free-media a { + color: #666; } + +div.jp-type-playlist div.jp-playlist span.jp-free-media a:hover { + color: #0d88c1; } + +span.jp-artist { + font-size: .8em; + color: #666; } + +/* @end */ +.jp-video-play { + width: 100%; + overflow: hidden; + /* Important for nested negative margins to work in modern browsers */ + cursor: pointer; + background-color: transparent; + /* Makes IE9 work with the active area over the whole video area. IE6/7/8 only have the button as active area. */ } + +.jp-video-270p .jp-video-play { + margin-top: -270px; + height: 270px; } + +.jp-video-360p .jp-video-play { + margin-top: -360px; + height: 360px; } + +.jp-video-full .jp-video-play { + height: 100%; } + +.jp-video-play-icon { + position: relative; + display: block; + width: 112px; + height: 100px; + margin-left: -56px; + margin-top: -50px; + left: 50%; + top: 50%; + background: url("/assets/jplayer.blue.monday.video.play.png") 0 0 no-repeat; + text-indent: -9999px; + border: none; + cursor: pointer; } + +.jp-video-play-icon:focus, .jp-video-play-icon:hover { + background: url("/assets/jplayer.blue.monday.video.play.png") 0 -100px no-repeat; } +.jp-state-playing .jp-video-play-icon { + background: url("/assets/jplayer.blue.monday.video.pause.png") 0 0 no-repeat;} + +.jp-state-playing .jp-video-play-icon:focus, .jp-state-playing .jp-video-play-icon:hover { + background: url("/assets/jplayer.blue.monday.video.pause.png") 0 -105px no-repeat; } +.jp-jplayer audio, +.jp-jplayer { + width: 0px; + height: 0px; } + +.jp-jplayer { + background-color: #000000; } + +/* @group TOGGLES */ +/* The audio toggles are nested inside jp-time-holder */ +.jp-toggles { + padding: 0; + margin: 0 auto; + overflow: hidden; } + +.jp-audio .jp-type-single .jp-toggles { + width: 25px; } + +.jp-audio .jp-type-playlist .jp-toggles { + width: 55px; + margin: 0; + position: absolute; + left: 325px; + top: 50px; } + +.jp-video .jp-toggles { + position: absolute; + left: 280px; + margin: 0; + margin-top: 10px; + width: 100px; } + +.jp-toggles button { + display: block; + float: left; + width: 25px; + height: 18px; + text-indent: -9999px; + line-height: 100%; + /* need this for IE6 */ + border: none; + cursor: pointer; } + +.jp-full-screen { + background: url("/assets/jplayer.blue.monday.jpg") 0 -310px no-repeat; + margin-left: 20px; } + +.jp-full-screen:focus { + background: url("/assets/jplayer.blue.monday.jpg") -30px -310px no-repeat; } + +.jp-state-full-screen .jp-full-screen { + background: url("/assets/jplayer.blue.monday.jpg") -60px -310px no-repeat; } + +.jp-state-full-screen .jp-full-screen:focus { + background: url("/assets/jplayer.blue.monday.jpg") -90px -310px no-repeat; } + +.jp-repeat { + background: url("/assets/jplayer.blue.monday.jpg") 0 -290px no-repeat; } + +.jp-repeat:focus { + background: url("/assets/jplayer.blue.monday.jpg") -30px -290px no-repeat; } + +.jp-state-looped .jp-repeat { + background: url("/assets/jplayer.blue.monday.jpg") -60px -290px no-repeat; } + +.jp-state-looped .jp-repeat:focus { + background: url("/assets/jplayer.blue.monday.jpg") -90px -290px no-repeat; } + +.jp-shuffle { + background: url("/assets/jplayer.blue.monday.jpg") 0 -270px no-repeat; + margin-left: 5px; } + +.jp-shuffle:focus { + background: url("/assets/jplayer.blue.monday.jpg") -30px -270px no-repeat; } + +.jp-state-shuffled .jp-shuffle { + background: url("/assets/jplayer.blue.monday.jpg") -60px -270px no-repeat; } + +.jp-state-shuffled .jp-shuffle:focus { + background: url("/assets/jplayer.blue.monday.jpg") -90px -270px no-repeat; } + +/* @end */ +/* @group NO SOLUTION error feedback */ +.jp-no-solution { + padding: 5px; + font-size: .8em; + background-color: #eee; + border: 2px solid #009be3; + color: #000; + display: none; } + +.jp-no-solution a { + color: #000; } + +.jp-no-solution span { + font-size: 1em; + display: block; + text-align: center; + font-weight: bold; } + +/* @end */ diff --git a/app/assets/stylesheets/video_pro/jplayer.blue.monday.min.css b/app/assets/stylesheets/video_pro/jplayer.blue.monday.min.css new file mode 100644 index 0000000..07e9a79 --- /dev/null +++ b/app/assets/stylesheets/video_pro/jplayer.blue.monday.min.css @@ -0,0 +1 @@ +/*! Blue Monday Skin for jPlayer 2.9.2 ~ (c) 2009-2014 Happyworm Ltd ~ MIT License */.jp-audio :focus,.jp-audio-stream :focus,.jp-video :focus{outline:0}.jp-audio button::-moz-focus-inner,.jp-audio-stream button::-moz-focus-inner,.jp-video button::-moz-focus-inner{border:0}.jp-audio,.jp-audio-stream,.jp-video{font-size:1em;font-family:Verdana,Arial,sans-serif;line-height:1.6;color:#666;border:1px solid #009be3;background-color:#eee}.jp-audio{width:420px}.jp-audio-stream{width:182px}.jp-video-270p{width:480px}.jp-video-360p{width:640px}.jp-video-full{width:480px;height:270px;position:static!important;position:relative}.jp-video-full div div{z-index:1000}.jp-video-full .jp-jplayer{top:0;left:0;position:fixed!important;position:relative;overflow:hidden}.jp-video-full .jp-gui{position:fixed!important;position:static;top:0;left:0;width:100%;height:100%;z-index:1001}.jp-video-full .jp-interface{position:absolute!important;position:relative;bottom:0;left:0}.jp-interface{position:relative;background-color:#eee;width:100%}.jp-audio .jp-interface,.jp-audio-stream .jp-interface{height:80px}.jp-video .jp-interface{border-top:1px solid #009be3}.jp-controls-holder{clear:both;width:100%;margin:0 auto;position:relative;overflow:hidden;top:-8px}.jp-interface .jp-controls{margin:0;padding:0;overflow:hidden}.jp-audio .jp-controls{width:380px;padding:20px 20px 0}.jp-audio-stream .jp-controls{position:absolute;top:20px;left:20px;width:142px}.jp-video .jp-type-single .jp-controls{width:78px;margin-left:200px}.jp-video .jp-type-playlist .jp-controls{width:134px;margin-left:172px}.jp-video .jp-controls{float:left}.jp-controls button{display:block;float:left;overflow:hidden;text-indent:-9999px;border:none;cursor:pointer}.jp-play{width:40px;height:40px;background:url(/assets/jplayer.blue.monday.jpg) no-repeat}.jp-play:focus{background:url(/assets/jplayer.blue.monday.jpg) -41px 0 no-repeat}.jp-state-playing .jp-play{background:url(/assets/jplayer.blue.monday.jpg) 0 -42px no-repeat}.jp-state-playing .jp-play:focus{background:url(/assets/jplayer.blue.monday.jpg) -41px -42px no-repeat}.jp-next,.jp-previous,.jp-stop{width:28px;height:28px;margin-top:6px}.jp-stop{background:url(/assets/jplayer.blue.monday.jpg) 0 -83px no-repeat;margin-left:10px}.jp-stop:focus{background:url(/assets/jplayer.blue.monday.jpg) -29px -83px no-repeat}.jp-previous{background:url(/assets/jplayer.blue.monday.jpg) 0 -112px no-repeat}.jp-previous:focus{background:url(/assets/jplayer.blue.monday.jpg) -29px -112px no-repeat}.jp-next{background:url(/assets/jplayer.blue.monday.jpg) 0 -141px no-repeat}.jp-next:focus{background:url(/assets/jplayer.blue.monday.jpg) -29px -141px no-repeat}.jp-progress{overflow:hidden;background-color:#ddd}.jp-audio .jp-progress{position:absolute;top:32px;height:15px}.jp-audio .jp-type-single .jp-progress{left:110px;width:186px}.jp-audio .jp-type-playlist .jp-progress{left:166px;width:130px}.jp-video .jp-progress{top:0;left:0;width:100%;height:10px}.jp-seek-bar{background:url(/assets/jplayer.blue.monday.jpg) 0 -202px repeat-x;width:0;height:100%;cursor:pointer}.jp-play-bar{background:url(/assets/jplayer.blue.monday.jpg) 0 -218px repeat-x;width:0;height:100%}.jp-seeking-bg{background:url(/assets/jplayer.blue.monday.seeking.gif)}.jp-state-no-volume .jp-volume-controls{display:none}.jp-volume-controls{position:absolute;top:32px;left:308px;width:200px}.jp-audio-stream .jp-volume-controls{left:70px}.jp-video .jp-volume-controls{top:12px;left:50px}.jp-volume-controls button{display:block;position:absolute;overflow:hidden;text-indent:-9999px;border:none;cursor:pointer}.jp-mute,.jp-volume-max{width:18px;height:15px}.jp-volume-max{left:74px}.jp-mute{background:url(/assets/jplayer.blue.monday.jpg) 0 -170px no-repeat}.jp-mute:focus{background:url(/assets/jplayer.blue.monday.jpg) -19px -170px no-repeat}.jp-state-muted .jp-mute{background:url(/assets/jplayer.blue.monday.jpg) -60px -170px no-repeat}.jp-state-muted .jp-mute:focus{background:url(/assets/jplayer.blue.monday.jpg) -79px -170px no-repeat}.jp-volume-max{background:url(/assets/jplayer.blue.monday.jpg) 0 -186px no-repeat}.jp-volume-max:focus{background:url(/assets/jplayer.blue.monday.jpg) -19px -186px no-repeat}.jp-volume-bar{position:absolute;overflow:hidden;background:url(/assets/jplayer.blue.monday.jpg) 0 -250px repeat-x;top:5px;left:22px;width:46px;height:5px;cursor:pointer}.jp-volume-bar-value{background:url(/assets/jplayer.blue.monday.jpg) 0 -256px repeat-x;width:0;height:5px}.jp-audio .jp-time-holder{position:absolute;top:50px}.jp-audio .jp-type-single .jp-time-holder{left:110px;width:186px}.jp-audio .jp-type-playlist .jp-time-holder{left:166px;width:130px}.jp-current-time,.jp-duration{width:60px;font-size:.64em;font-style:oblique}.jp-current-time{float:left;display:inline;cursor:default}.jp-duration{float:right;display:inline;text-align:right;cursor:pointer}.jp-video .jp-current-time{margin-left:20px}.jp-video .jp-duration{margin-right:20px}.jp-details{font-weight:700;text-align:center;cursor:default}.jp-details,.jp-playlist{width:100%;background-color:#ccc;border-top:1px solid #009be3}.jp-type-playlist .jp-details,.jp-type-single .jp-details{border-top:none}.jp-details .jp-title{margin:0;padding:5px 20px;font-size:.72em;font-weight:700}.jp-playlist ul{list-style-type:none;margin:0;padding:0 20px;font-size:.72em}.jp-playlist li{padding:5px 0 4px 20px;border-bottom:1px solid #eee}.jp-playlist li div{display:inline}div.jp-type-playlist div.jp-playlist li:last-child{padding:5px 0 5px 20px;border-bottom:none}div.jp-type-playlist div.jp-playlist li.jp-playlist-current{list-style-type:square;list-style-position:inside;padding-left:7px}div.jp-type-playlist div.jp-playlist a{color:#333;text-decoration:none}div.jp-type-playlist div.jp-playlist a.jp-playlist-current,div.jp-type-playlist div.jp-playlist a:hover{color:#0d88c1}div.jp-type-playlist div.jp-playlist a.jp-playlist-item-remove{float:right;display:inline;text-align:right;margin-right:10px;font-weight:700;color:#666}div.jp-type-playlist div.jp-playlist a.jp-playlist-item-remove:hover{color:#0d88c1}div.jp-type-playlist div.jp-playlist span.jp-free-media{float:right;display:inline;text-align:right;margin-right:10px}div.jp-type-playlist div.jp-playlist span.jp-free-media a{color:#666}div.jp-type-playlist div.jp-playlist span.jp-free-media a:hover{color:#0d88c1}span.jp-artist{font-size:.8em;color:#666}.jp-video-play{width:100%;overflow:hidden;cursor:pointer;background-color:transparent}.jp-video-270p .jp-video-play{margin-top:-270px;height:270px}.jp-video-360p .jp-video-play{margin-top:-360px;height:360px}.jp-video-full .jp-video-play{height:100%}.jp-video-play-icon{position:relative;display:block;width:112px;height:100px;margin-left:-56px;margin-top:-50px;left:50%;top:50%;background:url(/assets/jplayer.blue.monday.video.play.png) no-repeat;text-indent:-9999px;border:none;cursor:pointer}.jp-video-play-icon:focus,.jp-video-play-icon:hover{background:url(/assets/jplayer.blue.monday.video.play.png) 0 -100px no-repeat}.jp-state-playing .jp-video-play-icon{background: url("/assets/jplayer.blue.monday.video.pause.png") 0 0 no-repeat;}.jp-state-playing .jp-video-play-icon:focus,.jp-state-playing .jp-video-play-icon:hover{background: url("/assets/jplayer.blue.monday.video.pause.png") 0 -105px no-repeat;}.jp-jplayer,.jp-jplayer audio{width:0;height:0}.jp-jplayer{background-color:#000}.jp-toggles{padding:0;margin:0 auto;overflow:hidden}.jp-audio .jp-type-single .jp-toggles{width:25px}.jp-audio .jp-type-playlist .jp-toggles{width:55px;margin:0;position:absolute;left:325px;top:50px}.jp-video .jp-toggles{position:absolute;left:280px;margin:10px 0 0;width:100px}.jp-toggles button{display:block;float:left;width:25px;height:18px;text-indent:-9999px;line-height:100%;border:none;cursor:pointer}.jp-full-screen{background:url(/assets/jplayer.blue.monday.jpg) 0 -310px no-repeat;margin-left:20px}.jp-full-screen:focus{background:url(/assets/jplayer.blue.monday.jpg) -30px -310px no-repeat}.jp-state-full-screen .jp-full-screen{background:url(/assets/jplayer.blue.monday.jpg) -60px -310px no-repeat}.jp-state-full-screen .jp-full-screen:focus{background:url(/assets/jplayer.blue.monday.jpg) -90px -310px no-repeat}.jp-repeat{background:url(/assets/jplayer.blue.monday.jpg) 0 -290px no-repeat}.jp-repeat:focus{background:url(/assets/jplayer.blue.monday.jpg) -30px -290px no-repeat}.jp-state-looped .jp-repeat{background:url(/assets/jplayer.blue.monday.jpg) -60px -290px no-repeat}.jp-state-looped .jp-repeat:focus{background:url(/assets/jplayer.blue.monday.jpg) -90px -290px no-repeat}.jp-shuffle{background:url(/assets/jplayer.blue.monday.jpg) 0 -270px no-repeat;margin-left:5px}.jp-shuffle:focus{background:url(/assets/jplayer.blue.monday.jpg) -30px -270px no-repeat}.jp-state-shuffled .jp-shuffle{background:url(/assets/jplayer.blue.monday.jpg) -60px -270px no-repeat}.jp-state-shuffled .jp-shuffle:focus{background:url(/assets/jplayer.blue.monday.jpg) -90px -270px no-repeat}.jp-no-solution{padding:5px;font-size:.8em;background-color:#eee;border:2px solid #009be3;color:#000;display:none}.jp-no-solution a{color:#000}.jp-no-solution span{font-size:1em;display:block;text-align:center;font-weight:700} \ No newline at end of file diff --git a/app/assets/stylesheets/video_pro/jqcloud.min.css b/app/assets/stylesheets/video_pro/jqcloud.min.css new file mode 100644 index 0000000..85bab57 --- /dev/null +++ b/app/assets/stylesheets/video_pro/jqcloud.min.css @@ -0,0 +1 @@ +div.jqcloud{font-family:Helvetica,Arial,sans-serif;font-size:10px;line-height:normal}div.jqcloud a{font-size:inherit;text-decoration:none}div.jqcloud span.w10{font-size:550%}div.jqcloud span.w9{font-size:500%}div.jqcloud span.w8{font-size:450%}div.jqcloud span.w7{font-size:400%}div.jqcloud span.w6{font-size:350%}div.jqcloud span.w5{font-size:300%}div.jqcloud span.w4{font-size:250%}div.jqcloud span.w3{font-size:200%}div.jqcloud span.w2{font-size:150%}div.jqcloud span.w1{font-size:100%}div.jqcloud{color:#09f}div.jqcloud a{color:inherit}div.jqcloud a:hover{color:#0df}div.jqcloud a:hover{color:#0cf}div.jqcloud span.w10{color:#0cf}div.jqcloud span.w9{color:#0cf}div.jqcloud span.w8{color:#0cf}div.jqcloud span.w7{color:#39d}div.jqcloud span.w6{color:#90c5f0}div.jqcloud span.w5{color:#90a0dd}div.jqcloud span.w4{color:#90c5f0}div.jqcloud span.w3{color:#a0ddff}div.jqcloud span.w2{color:#9ce}div.jqcloud span.w1{color:#aab5f0}div.jqcloud{overflow:hidden;position:relative}div.jqcloud span{padding:0} \ No newline at end of file diff --git a/app/assets/stylesheets/video_pros.css b/app/assets/stylesheets/video_pros.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/video_pros.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/.keep b/app/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/admin/video_pros_controller.rb b/app/controllers/admin/video_pros_controller.rb new file mode 100644 index 0000000..c37e3ff --- /dev/null +++ b/app/controllers/admin/video_pros_controller.rb @@ -0,0 +1,76 @@ +class Admin::VideoProsController < OrbitAdminController + before_action ->(module_app = @app_title) { set_variables module_app } + + def index + @tags = @module_app.tags + @filter_fields = filter_fields(@categories, @tags) + @video_pro_setting = VideoProSetting.first + @video_images = VideoImage.order_by(sort).with_categories(filters("category")) + .with_tags(filters("tag")) + .with_status(filters("status")) + @video_images = search_data(@video_images,[:title]).page(params[:page]).per(10) + @table_fields = [:status, :category, :video_image, :title, "video_pro.postdate", "video_pro.deadline", "video_pro.desc", "video_pro.keyword", "video_pro.post_agency"] + if request.xhr? + render :partial=>'index_table' + end + end + + def edit + @video_image = VideoImage.find(params[:id]) + @item = [['Youtube',"1"],[t('video'),"2"]] #[['Youtube',"1"],[t('video'),"2"],[t('image'),"3"]] + @item_choose = @video_image.exchange_item + unless can_edit_or_delete?(@video_image) + render_401 + end + end + + def update + video_image = VideoImage.find(params[:id]) + video_image.update_user_id = current_user.id.to_s + video_image.save + video_image.update_attributes(video_image_params) + redirect_to params[:referer_url] + end + + def new + @video_image = VideoImage.new + @item = [['Youtube',"1"],[t('video'),"2"]] #[['Youtube',"1"],[t('video'),"2"],[t('image'),"3"]] + @tags = @module_app.tags || [] + @video_image.postdate = Date.today + end + + def create + video_image = VideoImage.new(video_image_params) + video_image.update_user_id = current_user.id.to_s + video_image.create_user_id = current_user.id.to_s + video_image.save + redirect_to params[:referer_url] + end + + def destroy + video_image = VideoImage.find params[:id] + video_image.destroy + redirect_to admin_video_pro_path(:page => params[:page]) + end + + def settings + @video_pro_setting = VideoProSetting.first + end + def update_settings + @video_pro_setting = VideoProSetting.first + @video_pro_setting.update_attributes(video_pro_setting_params) + redirect_to settings_admin_video_pros_path + end + + private + def video_pro_setting_params + params.require(:video_pro_setting).permit! + end + def video_image_params + params.require(:video_image).permit! + end + + def setup_vars + @module_app = ModuleApp.where(:key => "video_pro").first + end +end \ No newline at end of file diff --git a/app/controllers/video_pros_controller.rb b/app/controllers/video_pros_controller.rb new file mode 100644 index 0000000..27e2c8a --- /dev/null +++ b/app/controllers/video_pros_controller.rb @@ -0,0 +1,242 @@ +class VideoProsController < ApplicationController + def self.custom_widget_data + ac = ActionController::Base.new + ac.render_to_string("video_pros/custom_widget_data",:locals=>{:@custom_data_field=>@custom_data_field,:@field_name=>@field_name}) + end + def show + params = OrbitHelper.params + uid = params[:uid] + video_image = VideoImage.where(:uid => uid).first + snapshot_url = video_image && video_image.get_snapshot_url + return if snapshot_url.nil? + video_image.view_count += 1 + video_image.inc_count + { + "video_image" => video_image + } + end + def show_api + uid = params[:uid] + @video_image = VideoImage.where(:uid => uid).first + snapshot_url = @video_image && @video_image.get_snapshot_url + if snapshot_url.nil? + render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :formats => [:html] + return + end + @video_image.view_count += 1 + @video_image.inc_count + render :layout=>false + end + def index + params = OrbitHelper.params + page = OrbitHelper.page rescue Page.where(:url=>params[:url]).first + page_categories = OrbitHelper.page_categories + categories = [{:name=>I18n.t("video_pro.all_category"), :value=>"all"}] + if page_categories.blank? || page_categories.include?('all') + categories_for_page = Category.where(:module_app_id=>ModuleApp.where(:key=>'video_pro').pluck(:id).first) + else + categories_for_page = Category.where(:id=>page_categories) + end + categories += categories_for_page.map do |c| + {:name=>c.title, :value=>c.id.to_s} + end + selected_category = params["category"] + if selected_category.present? && selected_category != 'all' + categories.each do |h| + if h[:value] == selected_category + h[:is_selected] = "selected" + break + end + end + filter_categories = [selected_category] + else + filter_categories = page_categories + end + @video_pro_setting = VideoProSetting.first + post_agencies = [] + id_name_mapping = User.where(:id.in=>@video_pro_setting.exist_user_ids.to_a).pluck(:id, "member_name.#{I18n.locale}").map{|k,v| [k.to_s, (v ? v.values.last : nil)]}.to_h + if @video_pro_setting.enable_name_mapping + @video_pro_setting.user_mapping.to_h.each do |id, name_trans| + id_name_mapping[id] = name_trans + end + end + @video_pro_setting.exist_user_ids.each do |user_id| + name_trans = id_name_mapping[user_id] + post_agencies << {:name=>name_trans, :value=>"m-#{user_id}"} if name_trans.present? + end + tmp_post_agencies = @video_pro_setting.post_agencies + @video_pro_setting.exist_post_agencies.each do |idx| + name_trans = tmp_post_agencies[idx] + post_agencies << {:name=>name_trans, :value=>"p-#{idx}"} if name_trans.present? + end + selected_post_agency = params["poster"] + if selected_post_agency.blank? && post_agencies.count > 0 && params["layout_type"].include?('post_agency') + selected_post_agency = post_agencies[0][:value] + end + if selected_post_agency.present? + post_agencies.each do |h| + if h[:value] == selected_post_agency + h[:is_selected] = "selected" + break + end + end + end + post_agencies = post_agencies.map do |post_agency| + {"option"=>""} + end + categories = categories.map do |category| + {"option"=>""} + end + video_images = VideoImage.where(:title.nin => ["",nil]) + page_url = "/#{I18n.locale}#{(page.get_url rescue page.url)}" + page_tabs = [ + {"klass"=>"", "url"=>page_url, "title"=>I18n.t('video_pro.latest_ranking')}, + {"klass"=>"", "url"=>page_url + '?hot=hot', "title"=>I18n.t('video_pro.top_ranking')} + ] + if params[:hot] == 'hot' + video_images = video_images.order(:view_count=>-1) + page_tabs[1]["klass"] = "now_view" + else + page_tabs[0]["klass"] = "now_view" + end + selected_tag = params['tags'] + if selected_tag.present? + filter_tags = [selected_tag] + else + filter_tags = OrbitHelper.page_tags + end + video_images = video_images.can_display_and_sorted.filter_by_categories(filter_categories).filter_by_tags(filter_tags) + search_value = params[:search].to_s.strip + if search_value.present? + keywords = search_value.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/) + regex = Regexp.union(keywords.map{|word| Regexp.new(".*"+Regexp.escape(word)+".*", "i")}) + video_images = video_images.where({"title" => regex}) + end + if selected_post_agency.present? + selected_type = selected_post_agency[0] + if selected_type == 'm' + video_images = video_images.where(:use_override_post_agency=>false, :update_user_id=>selected_post_agency.split('-').last) + elsif selected_type == 'p' + video_images = video_images.where(:use_override_post_agency=>true, :override_post_agency=>selected_post_agency.split('-').last) + end + end + custom_data_field = (page.custom_data_field || {} rescue {}) + videos = get_videos(video_images, OrbitHelper.url_to_show(''), custom_data_field) + hd_icon_url = "/assets/video_pro/icon_hd.png" + view_icon_url = "/assets/video_pro/icon_view.png" + search_placeholder = I18n.t("video_pro.search_placeholder") + search_text1 = I18n.t("video_pro.search_text1") + search_text2 = I18n.t("video_pro.search_text2") + { + "extras" => { + "search_placeholder" => search_placeholder, + "search_text1" => search_text1, + "search_text2" => search_text2, + "search_value" => search_value, + "keyword_trans" => I18n.t("video_pro.keyword"), + "view_count_trans" => I18n.t("video_pro.view_count"), + "hd_icon_url" => hd_icon_url, + "view_icon_url" => view_icon_url, + "more" => "More", + }, + "categories" => categories, + "post_agencies" => post_agencies, + "page_tabs" => page_tabs, + "videos" => videos, + "total_pages" => video_images.total_pages + } + end + def widget + subpart = OrbitHelper.get_current_widget + if subpart.widget_type.include?('jqcloud') + tags = subpart.tags + if tags.include?('all') + tags = Tag.where(:module_app_ids.in=>ModuleApp.where(:key=>'video_pro').pluck(:id)).to_a + else + tags = Tag.where(:id.in=>tags).to_a + end + show_url = OrbitHelper.widget_item_url('') + jqcloud_words = tags.map do |tag| + { + "text" => tag.name, + "weight"=> Tagging.where(:tag_id=>tag).count, + "link" => "#{show_url}?tags=#{tag.id}" + } + end.sort_by{|h| h["weight"]}.reverse! + { + "extras" => { + "jqcloud_words" => jqcloud_words.to_json + } + } + else + video_images = VideoImage.where(:title.nin => ["",nil]).can_display_and_sorted.filter_by_widget_categories.to_a + custom_data_field = subpart.custom_data_field || {} + @video_pro_setting = VideoProSetting.first + videos = get_videos(video_images, OrbitHelper.widget_item_url(''), custom_data_field) + hd_icon_url = "/assets/video_pro/icon_hd.png" + view_icon_url = "/assets/video_pro/icon_view.png" + { + "extras" => { + "keyword_trans" => I18n.t("video_pro.keyword"), + "view_count_trans" => I18n.t("video_pro.view_count"), + "hd_icon_url" => hd_icon_url, + "view_icon_url" => view_icon_url, + "more" => "More", + }, + "videos" => videos + } + end + end + + private + def get_videos(video_images, show_url, custom_data_field={}) + @autoplay_video = custom_data_field[:autoplay_video] rescue "0" + @hide_video_tools = custom_data_field[:hide_video_tools] == "1" rescue false + videos = [] + video_images.each_with_index do |video_image,i| + if video_image.language_enabled.include?(I18n.locale.to_s) + snapshot_url = video_image.get_snapshot_url + next if snapshot_url.nil? + video_post_agency = video_image.post_agency(@video_pro_setting) + video_postdate = video_image.postdate.to_s + video_category = video_image.category_title + statuses = video_image.statuses_with_classname + video_desc = video_image.desc + video_desc_escape = video_desc.gsub('"',""") rescue "" + video_title = video_image.title.to_s + video_title_escape = video_title.gsub('"','"') + video_keyword = video_image.keyword.to_s + if video_image.exchange_item == "1" + video_url = video_image.embed_url + video_webm_url = "" + video_type = "youtube" + elsif video_image.exchange_item == "2" + video_url = video_image.video_file.url rescue nil + video_type = "jplayer" + video_webm_url = video_image.video_file_webm.url rescue nil + has_jplayer = true + end + slug = video_image.to_param + api_url = "/xhr/video_pro/show_api/#{slug}" + videos << { + "api_url" => api_url, + "video_show_url" => show_url + slug, + "video_category" => video_category, + "statuses" => statuses, + "video_post_agency" => video_post_agency, + "video_postdate" => video_postdate, + "video_url" => video_url, + "video_webm_url" => video_webm_url, + "video_type" => video_type, + "snapshot_url" => snapshot_url, + "video_title" => video_title, + "video_title_escape" => video_title_escape, + "video_desc" => video_desc, + "video_keyword" => video_keyword, + "view_count" => video_image.view_count + } + end + end + videos + end +end diff --git a/app/helpers/admin/video_pros_helper.rb b/app/helpers/admin/video_pros_helper.rb new file mode 100644 index 0000000..3a9ca4a --- /dev/null +++ b/app/helpers/admin/video_pros_helper.rb @@ -0,0 +1,2 @@ +module Admin::VideoProsHelper +end diff --git a/app/helpers/video_pros_helper.rb b/app/helpers/video_pros_helper.rb new file mode 100644 index 0000000..462cdbe --- /dev/null +++ b/app/helpers/video_pros_helper.rb @@ -0,0 +1,2 @@ +module VideoProsHelper +end diff --git a/app/mailers/.keep b/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/video_image.rb b/app/models/video_image.rb new file mode 100644 index 0000000..c5daad7 --- /dev/null +++ b/app/models/video_image.rb @@ -0,0 +1,243 @@ +require 'uri' + +class VideoImage + include Mongoid::Document + include Mongoid::Timestamps + include OrbitModel::Status + include OrbitModel::Impression + include OrbitTag::Taggable + include OrbitCategory::Categorizable + include Slug + mount_uploader :file, VideoDataImageUploader + mount_uploader :video_snapshot, VideoDataImageUploader + mount_uploader :video_file, VideoDataUploader + mount_uploader :video_file_webm, VideoDataUploader + field :default_video_snapshot, type: Boolean, default: false + field :auto_convert_video, type: Boolean, default: false + field :title, as: :slug_title, type: String, localize: true + field :keyword, type: String, localize: true + field :desc, type: String, localize: true + # field :weight, type: Integer, default: 1 + # field :out_link, type: String + # field :link_open, type: String + field :postdate , type: Date, default: Date.today + field :deadline , type: Date + field :is_youtube, type: Boolean, default: false + field :youtube , type: String + field :youtube_id, type: String + field :sort_number, type: Integer + field :language_enabled, type: Array, default: ["en","zh_tw"] + field :exchange_item, default: "1" # 1=>youtube, 2=>video file, 3=>image + field :use_override_post_agency, type: Boolean, default: false + field :override_post_agency, type: Integer, default: 0 + field :create_user_id + field :update_user_id + field :view_count, type: Integer, default: 0 + field :scale, type: Float + # LINK_OPEN_TYPES = ["local", "new_window"] + + # before_save :add_http + # validates :file, presence: true + # validates :out_link, format: {:with=> /\A(http:\/\/|https:\/\/|\/)/i}, allow_blank: true + # validates :title, presence: true + scope :open_in_future, ->{where(:is_hidden.ne=>true,:is_preview.ne => true,:postdate.gt=>Time.now).order(postdate: :asc)} + scope :can_display, ->{where(:is_hidden.ne=>true).valid_time_range} + scope :can_display_and_sorted, ->{can_display.sorted} + scope :valid_time_range, ->{any_of({:postdate.lte=>Time.now, :deadline.gte=>Time.now},{:postdate.lte=>Time.now, :deadline=>nil},{:postdate=>nil,:deadline.gte=>Time.now},{:postdate=>nil,:deadline=>nil})} + scope :sorted, ->{order({is_top: :desc,postdate: :desc,id: :desc})} + + scope :is_expired, ->{self.and(VideoImage.unscoped.or({:deadline.lte=>Time.now}).selector)} + scope :not_expired, ->{self.and(VideoImage.unscoped.or({:deadline.gte=>Time.now},{:deadline=>nil}).selector)} + before_save do + unless @skip_callback + uri = URI.parse(self.youtube) rescue nil + self.is_youtube = (uri && uri.host == "www.youtube.com") + if self.is_youtube + if uri.path.start_with?('/embed/') + self.youtube_id = uri.path.split('/embed/').last.split(/[\/#?]/).first + if self.youtube_id.blank? + self.is_youtube = false + self.youtube_id = nil + end + else + params = CGI.parse(uri.query.to_s) + v = params.blank? ? nil : params['v'].first + if v.blank? + self.is_youtube = false + self.youtube_id = nil + else + self.youtube_id = v + end + end + if self.is_youtube + begin + temp_file = Tempfile.new('0.jpg', encoding: 'ascii-8bit') + snapshot_content = Net::HTTP.get_response(URI.parse("http:"+self.get_snapshot_url)).body rescue nil + temp_file.write(snapshot_content) + temp_file.close + image = MiniMagick::Image.open(temp_file.path) + self.scale = (1.0 * image[:height] / image[:width] * 100).round(2) + rescue => e + puts e.to_s + self.scale = nil + end + else + self.scale = nil + end + else + self.youtube_id = nil + image = MiniMagick::Image.open(self.video_snapshot.file.path) rescue nil + if image + self.scale = (1.0 * image[:height] / image[:width] * 100).round(2) + end + end + if self.video_snapshot_changed? + self.default_video_snapshot = false + end + VideoProSetting.first.update_user_id(self) + end + end + after_destroy do + VideoProSetting.first.remove_user_id(self) + end + after_save do + unless @skip_callback + if (self.video_file_changed? || self.auto_convert_video_changed?) && self.auto_convert_video + Thread.new do + self.generate_webm + end + end + if self.video_file? && self.video_file_changed? && (!(self.video_snapshot?) || self.default_video_snapshot) + Thread.new do + self.generate_video_snapshot + end + end + end + end + def inc_count + self.class.where(:id=>self.id).update_all({"$inc"=>{"view_count"=>1}}) + end + def category_title + self.category.title rescue "" + end + def post_agencies_translations + if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash + OrbitHelper::SharedHash['video_pro'][:post_agencies_translations] rescue VideoProSetting.first.post_agencies_translations + else + VideoProSetting.first.post_agencies_translations rescue {} + end + end + def get_override_post_agency + self.post_agencies_translations[I18n.locale.to_s][self.override_post_agency] rescue "" + end + def post_agency(video_pro_setting=nil) + if self.use_override_post_agency + self.get_override_post_agency + else + if video_pro_setting.nil? + video_pro_setting = VideoProSetting.first + end + if video_pro_setting && video_pro_setting.enable_name_mapping + tmp = video_pro_setting.user_mapping[self.update_user_id] rescue nil + if tmp.blank? + user_name = User.where(:id=>self.update_user_id).pluck(:member_name).first[I18n.locale.to_s] rescue nil + else + user_name = tmp + end + else + user_name = User.where(:id=>self.update_user_id).pluck(:member_name).first[I18n.locale.to_s] rescue nil + end + user_name + end + end + def generate_video_snapshot + if self.video_file? + self.default_video_snapshot = true + self[:video_snapshot] = File.basename(self.video_file.file.path).split(/\.[^.]+$/)[0] + ".jpg" + FileUtils.mkdir_p(File.dirname(self.video_snapshot.file.path)) + system("tmp/ffmpeg/ffmpeg -i #{self.video_file.file.path} -vframes 1 #{self.video_snapshot.file.path}") + @skip_callback = true + self.save + @skip_callback = false + true + end + end + def generate_webm + video_path = self.video_file.path rescue nil + if !video_path.blank? + video_webm = video_path.split('.')[0...-1].join('.')+".webm" + core_num = [`cat /proc/cpuinfo | grep processor | wc -l`.to_i/2,1].max + flag = system("tmp/ffmpeg/ffmpeg -i #{video_path} -c:v libvpx-vp9 -crf 35 -b:v 0 -b:a 96k -c:a libopus -filter:v fps=20 #{video_webm} -cpu-used #{core_num}") + if flag + self.video_file_webm = File.open(video_webm) + @skip_callback = true + self.save + @skip_callback = false + true + else + puts "generate webm failed" + end + end + end + + def expired? + self.deadline top_text, "classname" => "top"} if is_top? + statuses << {"name" => hot_text, "classname" => "hot"} if is_hot? + statuses << {"name" => hidden_text, "classname" => "hidden"} if is_hidden? + statuses + end + def status_for_table + status = "" + status << "#{top_text} " if self.is_top + status << "#{hot_text} " if self.is_hot + status << "#{hidden_text}"if self.is_hidden + status.html_safe + end + def top_text + I18n.t("announcement.status.top") + end + def hot_text + I18n.t("announcement.status.hot") + end + def hidden_text + I18n.t("announcement.status.hidden") + end + + def get_snapshot_url + (self.is_youtube ? self.youtube_thumb : (self.video_snapshot.url)) + end + protected + + def add_http + # unless self.out_link.blank? || self.out_link[/^http:\/\//] || self.out_link[/^https:\/\//] || self.out_link[/^\//] + # self.out_link = 'https://' + self.out_link + # end + end +end diff --git a/app/models/video_pro_setting.rb b/app/models/video_pro_setting.rb new file mode 100644 index 0000000..841964c --- /dev/null +++ b/app/models/video_pro_setting.rb @@ -0,0 +1,153 @@ +require 'uri' + +class VideoProSetting + include Mongoid::Document + include Mongoid::Timestamps + field :enable_name_mapping, type: Boolean, default: false + field :post_agencies, type: Array, default: [], localize: true + field :user_mapping, type: Hash, default: {}, localize: true + field :exist_user_ids, type: Array, default: [], localize: true + field :exist_post_agencies, type: Array, default: [], localize: true + before_save do + can_update_shared_hash = (defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash) + if can_update_shared_hash + OrbitHelper::SharedMutex.synchronize do + if self.post_agencies_changed? + OrbitHelper::SharedHash["video_pro"][:post_agencies_translations] = self.post_agencies_translations + end + end + end + tmp = self.user_mapping_translations + tmp.each do |locale, mapping| + mapping = mapping.select{|k,v| v.present?} + tmp[locale] = mapping + end + self.user_mapping_translations = tmp + end + def update_user_id(video_image) + save_flag = false + if video_image.use_override_post_agency + post_agency_was = video_image.override_post_agency_was + post_agency = video_image.override_post_agency + if video_image.override_post_agency_changed? || video_image.use_override_post_agency_changed? + tmp = self.exist_post_agencies_translations + if post_agency_was.present? + video_image.title_translations.each do |k, v| + tmp2 = tmp[k] + tmp2 = [] if tmp2.nil? + if v.present? && tmp2.include?(post_agency_was) && VideoImage.where(:id.ne=>video_image.id, :override_post_agency=>post_agency_was, :use_override_post_agency=>true).count == 0 + save_flag = true + tmp2.delete(post_agency_was) + end + end + end + if post_agency.present? + video_image.title_translations.each do |k, v| + if v.present? + tmp2 = tmp[k] + tmp2 = [] if tmp2.nil? + save_flag = true + tmp2 << post_agency unless tmp2.include?(post_agency) + end + end + end + self.exist_post_agencies_translations = tmp + end + else + user_id_was = video_image.update_user_id_was + user_id = video_image.update_user_id + if video_image.update_user_id_changed? || video_image.use_override_post_agency_changed? + tmp = self.exist_user_ids_translations + if user_id_was.present? + video_image.title_was.each do |k, v| + tmp2 = tmp[k] + tmp2 = [] if tmp2.nil? + if v.present? && tmp2.include?(user_id_was) && VideoImage.where(:id.ne=>video_image.id, :update_user_id=>user_id_was, :use_override_post_agency=>false).count == 0 + save_flag = true + tmp2.delete(user_id_was) + end + end + end + video_image.title_translations.each do |k, v| + if v.present? + tmp2 = tmp[k] + tmp2 = [] if tmp2.nil? + save_flag = true + tmp2 << user_id unless tmp2.include?(user_id) + end + end + self.exist_user_ids_translations = tmp + end + end + self.save if save_flag + end + def add_user_id(video_image) + save_flag = false + if video_image.use_override_post_agency + post_agency = video_image.override_post_agency + tmp = self.exist_post_agencies_translations + if post_agency.present? + video_image.title_translations.each do |k, v| + if v.present? + tmp2 = tmp[k] + tmp2 = [] if tmp2.nil? + save_flag = true + tmp2 << post_agency unless tmp2.include?(post_agency) + end + end + end + self.exist_post_agencies_translations = tmp + else + user_id = video_image.update_user_id + tmp = self.exist_user_ids_translations + video_image.title_translations.each do |k, v| + if v.present? + tmp2 = tmp[k] + tmp2 = [] if tmp2.nil? + save_flag = true + tmp2 << user_id unless tmp2.include?(user_id) + end + end + self.exist_user_ids_translations = tmp + end + self.save if save_flag + end + def remove_user_id(video_image) + save_flag = false + if video_image.use_override_post_agency + post_agency = video_image.override_post_agency + tmp = self.exist_post_agencies_translations + if post_agency.present? + video_image.title_translations.each do |k, v| + tmp2 = tmp[k] + tmp2 = [] if tmp2.nil? + if v.present? && tmp2.include?(post_agency) && VideoImage.where(:id.ne=>video_image.id, :override_post_agency=>post_agency, :use_override_post_agency=>true).count == 0 + save_flag = true + tmp2.delete(post_agency) + end + end + end + self.exist_post_agencies_translations = tmp + else + user_id = video_image.update_user_id + tmp = self.exist_user_ids_translations + video_image.title_translations.each do |k, v| + tmp2 = tmp[k] + tmp2 = [] if tmp2.nil? + if v.present? && tmp2.include?(user_id) && VideoImage.where(:id.ne=>video_image.id, :update_user_id=>user_id, :use_override_post_agency=>false).count == 0 + save_flag = true + tmp2.delete(user_id) + end + end + self.exist_user_ids_translations = tmp + end + self.save if save_flag + end + def get_user_name(user_id) + tmp = self.user_mapping[user_id] rescue nil + (tmp ? tmp : User.where(:id=>user_id).pluck(:member_name).first[I18n.locale.to_s] rescue nil) + end + def self.get_user_name(user_id) + User.where(:id=>user_id).pluck(:member_name).first[I18n.locale.to_s] rescue nil + end +end \ No newline at end of file diff --git a/app/uploaders/video_data_image_uploader.rb b/app/uploaders/video_data_image_uploader.rb new file mode 100644 index 0000000..51699bf --- /dev/null +++ b/app/uploaders/video_data_image_uploader.rb @@ -0,0 +1,90 @@ +# encoding: utf-8 +require 'carrierwave/processing/mime_types' + +class VideoDataImageUploader < CarrierWave::Uploader::Base + + # Include RMagick or MiniMagick support: + # include CarrierWave::RMagick + # include CarrierWave::MiniMagick + include CarrierWave::MiniMagick + include CarrierWave::MimeTypes + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :fog + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "uploads/video_data_image/#{mounted_as}/#{model.id}" + end + + # override + def filename + @original_filename + end + + # override + def original_filename=(filename) + @original_filename = super(filename) + + if(@original_filename.bytesize > 200) + original_file_extension = File.extname(@original_filename) + + @original_filename.force_encoding("ascii-8bit") + @original_filename = @original_filename[0, (200 - original_file_extension.bytesize)] + @original_filename.encode!("UTF-16BE", "UTF-8", :invalid => :replace, :undef => :replace, :replace => '') + @original_filename.encode!("UTF-8") + + @original_filename += original_file_extension + end + + @original_filename + end + + def fix_exif_rotation + manipulate! do |img| + img.tap(&:auto_orient) + end + end + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url + # # For Rails 3.1+ asset pipeline compatibility: + # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) + # + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process :scale => [200, 300] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + version :thumb do + process :fix_exif_rotation + process :resize_to_fit => [400, 400] + end + + version :mobile do + process :fix_exif_rotation + process :resize_to_limit => [1152, 768] + end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + def extension_white_list + %w(jpg jpeg gif png bmp) + end + + # Override the filename of the uploaded files: + # Avoid using model.id or version_name here, see uploader/store.rb for details. + # def filename + # "something.jpg" if original_filename + # end + + + +end diff --git a/app/uploaders/video_data_uploader.rb b/app/uploaders/video_data_uploader.rb new file mode 100644 index 0000000..0c7ea0e --- /dev/null +++ b/app/uploaders/video_data_uploader.rb @@ -0,0 +1,75 @@ +# encoding: utf-8 +require 'carrierwave/processing/mime_types' + +class VideoDataUploader < CarrierWave::Uploader::Base + + include CarrierWave::MimeTypes + + process :set_content_type + + # Include RMagick or ImageScience support: + # include CarrierWave::RMagick + # include CarrierWave::ImageScience + + # Choose what kind of storage to use for this uploader: + # storage :file + # storage :s3 + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "uploads/video_data_image/#{mounted_as}/#{model.id}" + end + + # override + def filename + @original_filename + end + + # override + def original_filename=(filename) + @original_filename = super(filename) + + if(@original_filename.bytesize > 200) + original_file_extension = File.extname(@original_filename) + @original_filename.encode!("UTF-8") + @original_filename = @original_filename[0, (200 - original_file_extension.bytesize)] + @original_filename += original_file_extension + end + + @original_filename + end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process :scale => [200, 300] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process :scale => [50, 50] + # end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + # def extension_white_list + # %w(jpg jpeg gif png) + # end + + # Override the filename of the uploaded files: + # def filename + # model.filename + # end + + def cache_dir + "#{Rails.root}/tmp/uploads" + end + +end diff --git a/app/views/.keep b/app/views/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/admin/video_pros/_form.html.erb b/app/views/admin/video_pros/_form.html.erb new file mode 100644 index 0000000..82f53bb --- /dev/null +++ b/app/views/admin/video_pros/_form.html.erb @@ -0,0 +1,369 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "video_data/jplayer.blue.monday.min" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/module-area" %> + <%= javascript_include_tag "validator" %> + <%= javascript_include_tag "video_data/jquery.jplayer.min" %> +<% end %> + +<%#= f.error_messages %> +<% + @video_pro_setting = VideoProSetting.first + @video_pro_setting = nil if @video_pro_setting && (!@video_pro_setting.enable_name_mapping) +%> + +
    + + + + +
    + + +
    + +
    + +
    + <%= select_category(f, @module_app) %> +
    +
    +
    + +
    +
    <%= t("choose_type") %>
    + <%= + select_tag "video_image[exchange_item]", options_for_select(@item,@item_choose) + %> +
    +
    + + + + + + + +
    + +
    + <% + current_user_id = current_user.id.to_s + if @video_image.update_user_id.blank? + update_user_id = current_user_id + else + update_user_id = @video_image.update_user_id + end + post_agency_text = "" + if @video_pro_setting + if update_user_id == current_user_id + post_agency_text = @video_pro_setting.get_user_name(update_user_id) + else + post_agency_text = "#{@video_pro_setting.get_user_name(update_user_id)} -> #{@video_pro_setting.get_user_name(current_user_id)}" + end + else + if update_user_id == current_user_id + post_agency_text = VideoProSetting.get_user_name(update_user_id) + else + post_agency_text = "#{VideoProSetting.get_user_name(update_user_id)} -> #{VideoProSetting.get_user_name(current_user_id)}" + end + end + %> + <%= select_tag "#{f.object_name}[use_override_post_agency]", options_for_select([[t("video_pro.the_same_as_publisher"), "0"], [t("video_pro.other"), "1"]], f.object.use_override_post_agency ? "1" : "0"), id: 'use_override_post_agency' %> +
    + <%= post_agency_text %> +
    +
    + <%= f.select("override_post_agency", (options_for_select(VideoProSetting.first.post_agencies.to_a.map.with_index{|agency,i| [agency, i] },:selected => f.object.override_post_agency) rescue [])) %> +
    +
    +
    + + +
    + +
    + <%= f.datetime_picker :postdate, :no_label => true, :picker_type=>'date', :format=>'yyyy/MM/dd' %> +
    +
    + + +
    + +
    + <%= f.datetime_picker :deadline, :no_label => true, :picker_type=>'date', :format=>'yyyy/MM/dd', :new_record => @video_image.new_record? %> +
    +
    + + +
    + +
    + <% @site_in_use_locales.each do |locale| %> + + <% end %> +
    +
    + +
    +
    + +
    + +
    + + + +
    +
    +
    + +
    +
    + + <%= select_tags(f, @module_app) %> +
    +
    +
    + + + + + +
    + + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
    "> + +
    + +
    + <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", value: (@video_image.title_translations[locale] rescue nil), placeholder: "#{t(locale.to_s)+t("title")}" %> + <% end %> +
    +
    + +
    + +
    +
    + <%= f.fields_for :desc_translations do |f| %> + <%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@video_image.desc_translations[locale] rescue nil) %> + <% end %> +
    +
    +
    + +
    + +
    + <%= f.fields_for :keyword_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", value: (@video_image.keyword_translations[locale] rescue nil) %> + <% end %> +
    +
    +
    + + <% end %> + +
    + +
    + + +
    + + <%= f.submit t('submit'), class: 'btn btn-primary' %> +
    + + + + + + + + diff --git a/app/views/admin/video_pros/_index_table.html.erb b/app/views/admin/video_pros/_index_table.html.erb new file mode 100644 index 0000000..a13a3cd --- /dev/null +++ b/app/views/admin/video_pros/_index_table.html.erb @@ -0,0 +1,71 @@ + + + + <% @table_fields.each do |f| %> + <%= thead(f) %> + <% end %> + + + + <% @video_images.each do |image| %> + + + + + + + + + + + + <% end %> + +
    + <%= image.status_for_table %> + + <%= image.category_title %> + + <% if image.exchange_item == "1" %> + + <% elsif image.exchange_item == "2" %> + <% + video_snapshot_url = "" + video_snapshot_url = image.video_snapshot.url if image.video_snapshot.file %> + + <% elsif image.exchange_item == "3" %> + <%= image_tag image.file.thumb, :class => "video_data-image" %> + <% end %> + + <%= image.title.to_s.html_safe rescue "" %> + <% if can_edit_or_delete?(@video_data) %> + + <% end %> + + <%= image.postdate.strftime("%Y-%m-%d") rescue "" %> + + <%= image.deadline.strftime("%Y-%m-%d") rescue "" %> + + <%= image.desc %> + + <%= image.keyword %> + + <%= image.post_agency(@video_pro_setting) %> +
    <%= image.updated_at.strftime("%Y-%m-%d %H:%M") rescue "" %>
    +
    +
    + + <%= content_tag :div, paginate(@video_images), class: "pagination pagination-centered" %> +
    \ No newline at end of file diff --git a/app/views/admin/video_pros/_jplayer.html.erb b/app/views/admin/video_pros/_jplayer.html.erb new file mode 100644 index 0000000..d3af076 --- /dev/null +++ b/app/views/admin/video_pros/_jplayer.html.erb @@ -0,0 +1,421 @@ +<%= javascript_include_tag "video_data/jplayer_front" %> + + + diff --git a/app/views/admin/video_pros/edit.html.erb b/app/views/admin/video_pros/edit.html.erb new file mode 100644 index 0000000..064c9d1 --- /dev/null +++ b/app/views/admin/video_pros/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @video_image, url: admin_video_pro_path(@video_image.id), html: {class: "form-horizontal main-forms", onSubmit: "return checkSelect();"} do |f| %> +
    + <%= render partial: 'form', locals: {f: f} %> +
    +<% end %> \ No newline at end of file diff --git a/app/views/admin/video_pros/index.html.erb b/app/views/admin/video_pros/index.html.erb new file mode 100644 index 0000000..5c27f6e --- /dev/null +++ b/app/views/admin/video_pros/index.html.erb @@ -0,0 +1,37 @@ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/jquery-ui-sortable.min" %> +<% end %> +<% content_for :page_specific_css do %> + +<% end %> +<%= render_filter @filter_fields, "index_table" %> + + <%= render 'index_table'%> + \ No newline at end of file diff --git a/app/views/admin/video_pros/new.html.erb b/app/views/admin/video_pros/new.html.erb new file mode 100644 index 0000000..128a828 --- /dev/null +++ b/app/views/admin/video_pros/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @video_image, url: admin_video_pros_path, html: {class: "form-horizontal main-forms", onSubmit: "return checkSelect();"} do |f| %> +
    + <%= render partial: 'form', locals: {f: f} %> +
    +<% end %> \ No newline at end of file diff --git a/app/views/admin/video_pros/settings.html.erb b/app/views/admin/video_pros/settings.html.erb new file mode 100644 index 0000000..8936b5b --- /dev/null +++ b/app/views/admin/video_pros/settings.html.erb @@ -0,0 +1,107 @@ +<%= stylesheet_link_tag "lib/togglebox"%> + +<%= form_for @video_pro_setting, url: update_settings_admin_video_pros_path, html: {class: "form-horizontal main-forms"} do |f| %> +
    +
    + +
    +
    + <% f.object.post_agencies.to_a.each_with_index do |dept, idx| %> +
    +
    + <% @site_in_use_locales.each_with_index do |locale, i| %> +
    " id="post_agencies_<%=idx%>_<%= locale %>"> + <%= f.fields_for :post_agencies_translations,f.object do |f| %> + <%= f.text_field "#{locale}][", :value => (f.object.post_agencies_translations[locale][idx] rescue ""), :placeholder=>t("video_pro.post_agency", :id=>nil) %> + <% end %> +
    + <% end %> +
    +
    + <% @site_in_use_locales.each_with_index do |locale, i| %> + " href="#post_agencies_<%=idx%>_<%= locale %>" data-toggle="tab"><%= t(locale.to_s) %> + <% end %> +
    + +
    + <% end %> + +
    +
    +
    +
    + +
    + +
    +
    + + + +
    + <% @site_in_use_locales.each_with_index do |locale, i| %> +
      "> + <% User.where(:beta_tester.ne=>true).each do |user| %> + <% user_id = user.id.to_s %> +
    • + +
      +
      + <%= f.fields_for :user_mapping_translations do |f| %> + <%= f.fields_for locale do |f| %> + <%= f.text_field user_id, value: (@video_pro_setting.user_mapping_translations[locale][user_id] rescue nil), class: "input-block-level" %> + <% end %> + <% end %> +
      +
      +
    • + <% end %> +
    + <% end %> +
    + +
    + + <%= f.submit t('submit'), class: 'btn btn-primary' %> +
    +
    +<% end %> + \ No newline at end of file diff --git a/app/views/video_pros/custom_widget_data.html.erb b/app/views/video_pros/custom_widget_data.html.erb new file mode 100644 index 0000000..db65ed4 --- /dev/null +++ b/app/views/video_pros/custom_widget_data.html.erb @@ -0,0 +1,28 @@ +
    +
    + +
    + <%= hidden_field_tag("#{@field_name}[custom_data_field][autoplay_video]","0") %> + <%= check_box_tag("#{@field_name}[custom_data_field][autoplay_video]", "1" ,(@custom_data_field["autoplay_video"] == "1" rescue false), :id=>"autoplay_video" )%> +
    +
    +
    + +
    + <%= hidden_field_tag("#{@field_name}[custom_data_field][hide_video_tools]","0") %> + <%= check_box_tag("#{@field_name}[custom_data_field][hide_video_tools]", "1" ,(@custom_data_field["hide_video_tools"] == "1" rescue false), :id=>"hide_video_tools" )%> +
    +
    +
    + \ No newline at end of file diff --git a/app/views/video_pros/index.html.erb b/app/views/video_pros/index.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/video_pros/index.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/app/views/video_pros/show.html.erb b/app/views/video_pros/show.html.erb new file mode 100644 index 0000000..d44f4c3 --- /dev/null +++ b/app/views/video_pros/show.html.erb @@ -0,0 +1,86 @@ +<% + data = action_data + video_image = data["video_image"] + video_title = video_image.title.to_s + video_desc = video_image.desc.to_s + video_post_agency = video_image.post_agency.to_s + video_postdate = video_image.postdate.to_s + if video_image.is_youtube + video_url = video_image.embed_url + video_webm_url = nil + else + video_url = video_image.video_file.url + video_webm_url = video_image.video_file_webm.url + end + hd_icon_url = "/assets/video_pro/icon_hd.png" + view_icon_url = "/assets/video_pro/icon_view.png" + view_count_trans = I18n.t("video_pro.view_count") + view_count = video_image.view_count + autoplay_video = false + hide_video_tools = false + snapshot_url = video_image.get_snapshot_url + @is_frontend = true + video_scale = (video_image.scale ? video_image.scale : 56.25) +%> +
    +

    <%= video_title %>

    + <% if video_image.is_youtube %> +
    + +
    + <% else %> + <%= stylesheet_link_tag("video_pro/jplayer.blue.monday.min.css") %> + <%= javascript_include_tag("video_pro/jquery.jplayer.min.js") %> +
    +
    + <%= render partial: "admin/video_pros/jplayer", locals:{i: "video_file",file_name: video_title,file_url: video_url,file_webm_url: video_webm_url,:@autoplay_video=> autoplay_video,:@apply_autoplay_script=>true,:@hide_video_tools=> hide_video_tools,:@is_frontend=>true,:@file_poster=> snapshot_url} %> +
    +
    + <% end %> +
    +
    <%= video_post_agency %> | <%= video_postdate %>
    +
    <%= video_desc %>
    +
    + HD + <%= view_count_trans %>x <%= view_count %> +
    +
    + +
    \ No newline at end of file diff --git a/app/views/video_pros/show_api.html.erb b/app/views/video_pros/show_api.html.erb new file mode 100644 index 0000000..befa052 --- /dev/null +++ b/app/views/video_pros/show_api.html.erb @@ -0,0 +1,58 @@ +<% + autoplay_video = false + hide_video_tools = false + snapshot_url = @video_image.get_snapshot_url + @is_frontend = true + video_scale = (@video_image.scale ? @video_image.scale : 56.25) +%> + +<% if @video_image.is_youtube %> +
    + +
    +<% else %> +<%= stylesheet_link_tag("video_pro/jplayer.blue.monday.min.css") %> +<%= javascript_include_tag("video_pro/jquery.jplayer.min.js") %> +
    +
    + <%= render partial: "admin/video_pros/jplayer", locals:{i: "video_file",file_name: @video_image.title,file_url: @video_image.video_file.url,file_webm_url: @video_image.video_file_webm.url,:@autoplay_video=> autoplay_video,:@apply_autoplay_script=>true,:@hide_video_tools=> hide_video_tools,:@is_frontend=>true,:@file_poster=> snapshot_url,:@bind_autoheight_callback=>'window.fix_video_modal_width'} %> +
    +
    +<% end %> + \ No newline at end of file diff --git a/bin/rails b/bin/rails new file mode 100644 index 0000000..9e8b19a --- /dev/null +++ b/bin/rails @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. + +ENGINE_ROOT = File.expand_path('../..', __FILE__) +ENGINE_PATH = File.expand_path('../../lib/video_pro/engine', __FILE__) + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) + +require "action_controller/railtie" +require "action_mailer/railtie" +require "sprockets/railtie" +require "rails/test_unit/railtie" +require "mongoid" +require 'rails/engine/commands' diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..f692bde --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,71 @@ +en: + module_name: + video_pro: "Video" + video_image: "Video" + video_pro: + latest_ranking: "Latest Ranking" + top_ranking: "Top Ranking" + search_placeholder: "Please input keywords" + search_text1: "Search" + search_text2: "Search" + all_category: "All Category" + view_count: "View Count" + the_same_as_publisher: "The same as Publisher" + other: "Other" + post_agency: "Post Agency" + desc: "Description" + enable_name_mapping: "Enable Name Mapping" + keyword: "Keyword" + language_enabled: "Language Enabled" + postdate: "Post Date" + deadline: "End Date" + video_snapshot: "Video Snapshot" + auto_convert_video: Auto Convert Video to webm(reduce usage for network traffic) + autoplay_video: "Autoplay Video(play mute)" + hide_video_tools: Hide video tools + select_video: Select Video + please_choose_exchange_item: Please Choose Item Type + video_pro: Video + video_data: Video + video_data_name: Video Name + edit_video_data: Edit Video + effect: Effect + enter_number: Please enter a number + enter_url: Please enter the URL + local: Open In Current page + name_only_english: Video Name can only in English + new_video_data: New Video + new_window: Open In New window + no_ie_10_effect_support: IE10 earlier do not support this effect + number_milliseconds: Please enter the number of milliseconds + number_seconds: Please enter the number of seconds + size: Size + transition_interval: Interval + transition_speed: Speed + type: Link Open Type + video_data_name_note: Video Name only english + ste: Transition Interval + ste_note: Please enter the number of seconds + best_size: Best Size + all: All + categories: Categories + add: Add + duration: Duration + setting: Settings + expired: Expired + order: Order + order_images: Order Images + save_changes: Save Changes + close: Close + resume: Resume + pause: Pause + prev: Prev + next: Next + muted: Muted + unmuted: Unmuted + video: Video + new_image: New Image or Video + youtube: youtube embed URL + type: Image or Video + choose_type: Please Select One Type First + select: Please Select One \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml new file mode 100644 index 0000000..a67aed9 --- /dev/null +++ b/config/locales/zh_tw.yml @@ -0,0 +1,68 @@ +zh_tw: + module_name: + video_pro: "影片模組" + video_image: "影片" + video_pro: + latest_ranking: "最新排行" + top_ranking: "熱門排行" + search_placeholder: "請輸入關鍵字查詢" + search_text1: "搜尋" + search_text2: "查詢" + all_category: "全部類別" + view_count: "觀看人數" + the_same_as_publisher: "同發佈人" + other: "其他" + post_agency: "發佈單位" + desc: "描述" + enable_name_mapping: "啟用名字對照表" + keyword: "關鍵字" + language_enabled: "顯示語系" + postdate: "發佈時間" + deadline: "結束時間" + video_snapshot: "影片縮圖" + auto_convert_video: 自動轉換成webm格式(節省播放流量) + autoplay_video: "自動播放影片(會自動靜音)" + hide_video_tools: 隱藏影片工具 + select_video: 選擇影片 + please_choose_exchange_item: 請選擇欄位類型 + video_pro: 影片模組 + video_data: 橫幅 + video_data_name: 橫幅名稱 + name_only_english: 橫幅名稱只能為英文 + edit_video_data: 編輯橫幅 + enter_number: 請輸入數字 + enter_url: 請輸入網址 + local: 當前視窗開啟 + new_video_data: 新增橫幅 + new_window: 新視窗開啟 + ste: 轉換間隔時間 + number_seconds: 請輸入秒數 + number_milliseconds: 請輸入毫秒數 + best_size: 最佳尺寸 + effect: 效果 + all: 全部 + categories: 類別 + add: 新增 + size: 大小 + settings: 設定 + transition_interval: 轉換間隔 + transition_speed: 轉換速度 + type: 開啟方式 + expired: 已下架 + duration: 期間 + order: 排序 + order_images: 圖片順序 + save_changes: 儲存變更 + close: 取消 + resume: 繼續播放 + pause: 暫停播放 + prev: 上一張 + next: 下一張 + muted: 靜音 + unmuted: 取消靜音 + video: 影片 + new_image: 新增圖片 或 影片 + youtube: youtube網址嵌入 + type: 圖片 或 影片 + choose_type: 請先選擇類型 + select: 請選擇 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..d4ca002 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,22 @@ +Rails.application.routes.draw do + if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console') + video_pro_setting = VideoProSetting.first + if video_pro_setting.nil? + video_pro_setting = VideoProSetting.create + end + end + locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales + scope "(:locale)", locale: Regexp.new(locales.join("|")) do + namespace :admin do + post "/video_pro/save_image_order", to: "video_pros#save_image_order" + resources :video_pros do + collection do + get 'settings' + post 'update_settings' + patch 'update_settings' + end + end + end + end + get '/xhr/video_pro/show_api/(:title)-(:uid)', to: 'video_pros#show_api' +end diff --git a/lib/tasks/video_pro_tasks.rake b/lib/tasks/video_pro_tasks.rake new file mode 100644 index 0000000..592d6a1 --- /dev/null +++ b/lib/tasks/video_pro_tasks.rake @@ -0,0 +1,4 @@ +# desc "Explaining what the task does" +# task :video_pro do +# # Task goes here +# end diff --git a/lib/video_pro.rb b/lib/video_pro.rb new file mode 100644 index 0000000..ea48103 --- /dev/null +++ b/lib/video_pro.rb @@ -0,0 +1,4 @@ +require "video_pro/engine" + +module VideoPro +end diff --git a/lib/video_pro/engine.rb b/lib/video_pro/engine.rb new file mode 100644 index 0000000..6a22025 --- /dev/null +++ b/lib/video_pro/engine.rb @@ -0,0 +1,52 @@ +module VideoPro + class Engine < ::Rails::Engine + initializer "video_pro" do + OrbitApp.registration "VideoPro", :type => "ModuleApp" do + module_label "video_pro.video_pro" + base_url File.expand_path File.dirname(__FILE__) + widget_methods ["widget"] + widget_settings [{"multiselect"=>false,"display_field"=>"title","enable_custom_widget_data"=>true}] + # models_to_cache [:video_data,:video_image] + taggable "VideoImage" + categorizable + authorizable + frontend_enabled + data_count 1..30 + + side_bar do + head_label_i18n 'video_pro.video_pro', icon_class: "icons-video" + available_for "sub_managers" + active_for_controllers (['admin/video_pros','admin/video_images']) + head_link_path "admin_video_pros_path" + + context_link 'video_pro.all', + :link_path=>"admin_video_pros_path" , + :priority=>1, + :active_for_action=>{'admin/video_pros'=>"index"}, + :available_for => 'sub_managers' + + context_link 'setting', + :link_path=>"settings_admin_video_pros_path" , + :priority=>1, + :active_for_action=>{'admin/video_pros'=>"settings"}, + :available_for => 'sub_managers' + + context_link 'categories', + :link_path=>"admin_module_app_categories_path" , + :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'video_pro').id}", + :priority=>3, + :active_for_action=>{'admin/video_pros'=>'categories'}, + :active_for_category => 'VideoPro', + :available_for => 'managers' + context_link 'tags', + :link_path=>"admin_module_app_tags_path" , + :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'video_pro').id}", + :priority=>5, + :active_for_action=>{'admin/video_pros'=>'tags'}, + :active_for_tag => 'VideoPro', + :available_for => 'managers' + end + end + end + end +end diff --git a/lib/video_pro/version.rb b/lib/video_pro/version.rb new file mode 100644 index 0000000..a52f876 --- /dev/null +++ b/lib/video_pro/version.rb @@ -0,0 +1,3 @@ +module VideoPro + VERSION = "0.0.1" +end diff --git a/modules/video_pro/_video_pro_widget1.html.erb b/modules/video_pro/_video_pro_widget1.html.erb new file mode 100644 index 0000000..07be0c6 --- /dev/null +++ b/modules/video_pro/_video_pro_widget1.html.erb @@ -0,0 +1,42 @@ +
    + +
    + +
    \ No newline at end of file diff --git a/modules/video_pro/_video_pro_widget_jqcloud1.html.erb b/modules/video_pro/_video_pro_widget_jqcloud1.html.erb new file mode 100644 index 0000000..1d48386 --- /dev/null +++ b/modules/video_pro/_video_pro_widget_jqcloud1.html.erb @@ -0,0 +1,20 @@ +
    + <%= javascript_include_tag 'video_pro/jqcloud.min' %> + <%= stylesheet_link_tag 'video_pro/jqcloud.min' %> +
    + +
    diff --git a/modules/video_pro/info.json b/modules/video_pro/info.json new file mode 100644 index 0000000..2d2056a --- /dev/null +++ b/modules/video_pro/info.json @@ -0,0 +1,54 @@ +{ + "widgets" : [ + { + "filename" : "video_pro_widget1", + "name" : { + "zh_tw" : "1. 影片列表1 ( 縮圖, 影片資訊, 頁面連結)", + "en" : "1. Video List 1 ( snapshot, video info, page link)" + }, + "thumbnail" : "thumb.png" + }, + { + "filename" : "video_pro_widget_jqcloud1", + "name" : { + "zh_tw" : "2. 影片文字雲(標籤)", + "en" : "2. Video Word Cloud(tags)" + }, + "thumbnail" : "thumb.png" + } + ], + "frontend" : [ + { + "filename" : "video_pro_index1", + "name" : { + "zh_tw" : "1. 影片列表1 ( 縮圖, 影片資訊, 頁面連結)", + "en" : "1. Video List 1 ( snapshot, video info, page link)" + }, + "thumbnail" : "thumb.png" + }, + { + "filename" : "video_pro_index2", + "name" : { + "zh_tw" : "2. 影片列表1 + 類別 + 搜尋 ( 縮圖, 影片資訊, 頁面連結)", + "en" : "2. Video List 1 + Category filter + Search ( snapshot, video info, page link)" + }, + "thumbnail" : "thumb.png" + }, + { + "filename" : "video_pro_index3", + "name" : { + "zh_tw" : "3. 影片列表2 + 懸浮框 ( 縮圖, 影片資訊)", + "en" : "3. Video List 2 + Modal window ( snapshot, video info)" + }, + "thumbnail" : "thumb.png" + }, + { + "filename" : "video_pro_index_post_agency1", + "name" : { + "zh_tw" : "4. 影片列表3 + 發佈單位篩選 ( 縮圖, 影片資訊, 關鍵字, 頁面連結)", + "en" : "4. Video List 3 + Post Agency filter ( snapshot, video info, keyword, page link)" + }, + "thumbnail" : "thumb.png" + } + ] +} \ No newline at end of file diff --git a/modules/video_pro/thumbs/thumb.png b/modules/video_pro/thumbs/thumb.png new file mode 100644 index 0000000..266af56 Binary files /dev/null and b/modules/video_pro/thumbs/thumb.png differ diff --git a/modules/video_pro/video_pro_index1.html.erb b/modules/video_pro/video_pro_index1.html.erb new file mode 100644 index 0000000..0b1cac0 --- /dev/null +++ b/modules/video_pro/video_pro_index1.html.erb @@ -0,0 +1,43 @@ +
    + +
    + +
    +{{pagination_goes_here}} \ No newline at end of file diff --git a/modules/video_pro/video_pro_index2.html.erb b/modules/video_pro/video_pro_index2.html.erb new file mode 100644 index 0000000..165ec8d --- /dev/null +++ b/modules/video_pro/video_pro_index2.html.erb @@ -0,0 +1,141 @@ +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    + +
    + + +
    +{{pagination_goes_here}} \ No newline at end of file diff --git a/modules/video_pro/video_pro_index3.html.erb b/modules/video_pro/video_pro_index3.html.erb new file mode 100644 index 0000000..5068e81 --- /dev/null +++ b/modules/video_pro/video_pro_index3.html.erb @@ -0,0 +1,70 @@ +
    + + +
    + + +
    +{{pagination_goes_here}} \ No newline at end of file diff --git a/modules/video_pro/video_pro_index_post_agency1.html.erb b/modules/video_pro/video_pro_index_post_agency1.html.erb new file mode 100644 index 0000000..ce74a1d --- /dev/null +++ b/modules/video_pro/video_pro_index_post_agency1.html.erb @@ -0,0 +1,97 @@ +
    +
    +
    +
    + +
    +
    +
    +
    + +
    + + +
    +{{pagination_goes_here}} \ No newline at end of file diff --git a/test/controllers/admin/video_pros_controller_test.rb b/test/controllers/admin/video_pros_controller_test.rb new file mode 100644 index 0000000..acc9d09 --- /dev/null +++ b/test/controllers/admin/video_pros_controller_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class Admin::VideoProsControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + + test "should get new" do + get :new + assert_response :success + end + + test "should get create" do + get :create + assert_response :success + end + +end diff --git a/test/controllers/video_pros_controller_test.rb b/test/controllers/video_pros_controller_test.rb new file mode 100644 index 0000000..e6fd2de --- /dev/null +++ b/test/controllers/video_pros_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class VideoProsControllerTest < ActionController::TestCase + test "should get widget" do + get :widget + assert_response :success + end + +end diff --git a/test/dummy/README.rdoc b/test/dummy/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/test/dummy/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile new file mode 100644 index 0000000..ba6b733 --- /dev/null +++ b/test/dummy/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/test/dummy/app/assets/images/.keep b/test/dummy/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js new file mode 100644 index 0000000..5bc2e1c --- /dev/null +++ b/test/dummy/app/assets/javascripts/application.js @@ -0,0 +1,13 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/test/dummy/app/assets/stylesheets/application.css b/test/dummy/app/assets/stylesheets/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/test/dummy/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/test/dummy/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/test/dummy/app/controllers/concerns/.keep b/test/dummy/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/test/dummy/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test/dummy/app/mailers/.keep b/test/dummy/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/models/.keep b/test/dummy/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/models/concerns/.keep b/test/dummy/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb new file mode 100644 index 0000000..593a778 --- /dev/null +++ b/test/dummy/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Dummy + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test/dummy/bin/bundle b/test/dummy/bin/bundle new file mode 100644 index 0000000..66e9889 --- /dev/null +++ b/test/dummy/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails new file mode 100644 index 0000000..728cd85 --- /dev/null +++ b/test/dummy/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake new file mode 100644 index 0000000..1724048 --- /dev/null +++ b/test/dummy/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test/dummy/config.ru b/test/dummy/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/test/dummy/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb new file mode 100644 index 0000000..5e395a8 --- /dev/null +++ b/test/dummy/config/application.rb @@ -0,0 +1,29 @@ +require File.expand_path('../boot', __FILE__) + +# Pick the frameworks you want: +# require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "sprockets/railtie" +require "rails/test_unit/railtie" + +Bundler.require(*Rails.groups) +require "video_pro" + +module Dummy + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end + diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb new file mode 100644 index 0000000..6266cfc --- /dev/null +++ b/test/dummy/config/boot.rb @@ -0,0 +1,5 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb new file mode 100644 index 0000000..ee8d90d --- /dev/null +++ b/test/dummy/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb new file mode 100644 index 0000000..a384d95 --- /dev/null +++ b/test/dummy/config/environments/development.rb @@ -0,0 +1,34 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb new file mode 100644 index 0000000..4f67ce3 --- /dev/null +++ b/test/dummy/config/environments/production.rb @@ -0,0 +1,80 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # Version of your assets, change this if you want to expire all your assets. + config.assets.version = '1.0' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. + # config.assets.precompile += %w( search.js ) + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new +end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb new file mode 100644 index 0000000..053f5b6 --- /dev/null +++ b/test/dummy/config/environments/test.rb @@ -0,0 +1,39 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/dummy/config/initializers/backtrace_silencers.rb b/test/dummy/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/test/dummy/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test/dummy/config/initializers/cookies_serializer.rb b/test/dummy/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7a06a89 --- /dev/null +++ b/test/dummy/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/test/dummy/config/initializers/inflections.rb b/test/dummy/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/test/dummy/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/test/dummy/config/initializers/mime_types.rb b/test/dummy/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/test/dummy/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/test/dummy/config/initializers/session_store.rb b/test/dummy/config/initializers/session_store.rb new file mode 100644 index 0000000..e766b67 --- /dev/null +++ b/test/dummy/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_dummy_session' diff --git a/test/dummy/config/initializers/wrap_parameters.rb b/test/dummy/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..b81ea74 --- /dev/null +++ b/test/dummy/config/initializers/wrap_parameters.rb @@ -0,0 +1,9 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end diff --git a/test/dummy/config/locales/en.yml b/test/dummy/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/test/dummy/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb new file mode 100644 index 0000000..3f66539 --- /dev/null +++ b/test/dummy/config/routes.rb @@ -0,0 +1,56 @@ +Rails.application.routes.draw do + # The priority is based upon order of creation: first created -> highest priority. + # See how all your routes lay out with "rake routes". + + # You can have the root of your site routed with "root" + # root 'welcome#index' + + # Example of regular route: + # get 'products/:id' => 'catalog#view' + + # Example of named route that can be invoked with purchase_url(id: product.id) + # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase + + # Example resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Example resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Example resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Example resource route with more complex sub-resources: + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', on: :collection + # end + # end + + # Example resource route with concerns: + # concern :toggleable do + # post 'toggle' + # end + # resources :posts, concerns: :toggleable + # resources :photos, concerns: :toggleable + + # Example resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end +end diff --git a/test/dummy/config/secrets.yml b/test/dummy/config/secrets.yml new file mode 100644 index 0000000..1674bae --- /dev/null +++ b/test/dummy/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: da32ed1abd0044ae97c6bc18b67b5e554c9c979970b02f1fa2d9353c61a23152e56466b35630d44c29b32fbe775341f6307aafb9a5758a92eef1e737bcde42f0 + +test: + secret_key_base: 939dbbde912d62e38c32f29a4d1603ed7ca30583cfd73aea8da11bdd812b49dced94b30e7dc1cb89844fb90bbf501db092a52b9dc896343d0c058d7d0b9f822c + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/test/dummy/lib/assets/.keep b/test/dummy/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/log/.keep b/test/dummy/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/public/404.html b/test/dummy/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/test/dummy/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
    +
    +

    The page you were looking for doesn't exist.

    +

    You may have mistyped the address or the page may have moved.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/422.html b/test/dummy/public/422.html new file mode 100644 index 0000000..a21f82b --- /dev/null +++ b/test/dummy/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
    +
    +

    The change you wanted was rejected.

    +

    Maybe you tried to change something you didn't have access to.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/500.html b/test/dummy/public/500.html new file mode 100644 index 0000000..061abc5 --- /dev/null +++ b/test/dummy/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
    +
    +

    We're sorry, but something went wrong.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/favicon.ico b/test/dummy/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/video_images.yml b/test/fixtures/video_images.yml new file mode 100644 index 0000000..490f8f7 --- /dev/null +++ b/test/fixtures/video_images.yml @@ -0,0 +1,15 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + context: MyString + weight: 1 + out_link: MyString + link_open: MyString + +two: + title: MyString + context: MyString + weight: 1 + out_link: MyString + link_open: MyString diff --git a/test/helpers/admin/video_pros_helper_test.rb b/test/helpers/admin/video_pros_helper_test.rb new file mode 100644 index 0000000..9c6f8d7 --- /dev/null +++ b/test/helpers/admin/video_pros_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Admin::VideoProsHelperTest < ActionView::TestCase +end diff --git a/test/helpers/video_pros_helper_test.rb b/test/helpers/video_pros_helper_test.rb new file mode 100644 index 0000000..e0c23de --- /dev/null +++ b/test/helpers/video_pros_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class VideoProsHelperTest < ActionView::TestCase +end diff --git a/test/integration/navigation_test.rb b/test/integration/navigation_test.rb new file mode 100644 index 0000000..eec8c0e --- /dev/null +++ b/test/integration/navigation_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class NavigationTest < ActionDispatch::IntegrationTest + + # test "the truth" do + # assert true + # end +end + diff --git a/test/models/video_image_test.rb b/test/models/video_image_test.rb new file mode 100644 index 0000000..e5bcc92 --- /dev/null +++ b/test/models/video_image_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class VideoImageTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..1e26a31 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,15 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require File.expand_path("../dummy/config/environment.rb", __FILE__) +require "rails/test_help" + +Rails.backtrace_cleaner.remove_silencers! + +# Load support files +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } + +# Load fixtures from the engine +if ActiveSupport::TestCase.method_defined?(:fixture_path=) + ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__) +end diff --git a/test/video_pro_test.rb b/test/video_pro_test.rb new file mode 100644 index 0000000..9ece7f5 --- /dev/null +++ b/test/video_pro_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class VideoProTest < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, VideoPro + end +end diff --git a/video_pro.gemspec b/video_pro.gemspec new file mode 100644 index 0000000..b23aef7 --- /dev/null +++ b/video_pro.gemspec @@ -0,0 +1,66 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "video_pro/version" +bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install' +if bundle_update_flag + require "fileutils" + app_path = File.expand_path(__dir__) + template_path = ENV['PWD'] + '/app/templates' + all_template = Dir.glob(template_path+'/*/') + puts 'copying module' + all_template.each do |folder| + if folder.split('/')[-1] != 'mobile' + begin + system ('cp -r '+ app_path + '/modules/ ' + folder) + rescue + puts 'error copy' + end + end + end + #download ffmpeg + begin + destination = ENV['PWD']+'/tmp/ffmpeg' + if Dir[destination].length==0 + FileUtils.mkdir_p("#{ENV['PWD']}/tmp") + require 'open-uri' + if RUBY_VERSION.to_f >= 2.7 + download = URI.open('https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.2/ffmpeg-4.2-linux-64.zip',:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE) + else + download = open('https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.2/ffmpeg-4.2-linux-64.zip',:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE) + end + save_zip_name = "#{ENV['PWD']}/tmp/ffmpeg-4.2-linux-64.zip" + IO.copy_stream(download, save_zip_name) + require 'zip' + FileUtils.mkdir_p(destination) + Zip::File.open(save_zip_name) do |zip_file| + zip_file.each do |f| + fpath = File.join(destination, f.name) + zip_file.extract(f, fpath) unless File.exist?(fpath) + end + end + end + rescue => e + FileUtils.rmdir(destination) rescue nil + puts ["download ffmpeg failed",e] + end +end +#./ffmpeg -i 2.mp4 -c:v libvpx-vp9 -crf 35 -b:v 0 -b:a 96k -c:a libopus -filter:v fps=20 output.webm -cpu-used 4 +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "video_pro" + s.version = VideoPro::VERSION + s.authors = ["Ruling Digital"] + s.email = ["orbit@rulingcom.com"] + s.homepage = "http://www.rulingcom.com" + s.summary = "Ad Video management" + s.description = "Create Video for Orbit" + s.license = "MIT" + s.metadata = { + "_require" => "#{File.expand_path("../app/models/video_pro_setting", __FILE__)}", + "global_hash" => "{post_agencies_translations: (VideoProSetting.first.post_agencies_translations rescue {})}" + } + + s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] + s.test_files = Dir["test/**/*"] +end