c80_flowplayer 0.1.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,24 @@
1
+ /*
2
+ * flowplayer.js 3.2.11. The Flowplayer API
3
+ *
4
+ * Copyright 2009-2011 Flowplayer Oy
5
+ *
6
+ * This file is part of Flowplayer.
7
+ *
8
+ * Flowplayer is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * Flowplayer is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ * Date: 2012-06-16 10:34:45 -0400 (Sat, 16 Jun 2012)
22
+ * Revision: 808
23
+ */
24
+ (function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p<r&&q.call(s,p,s)!==false;s=t[++p]){}}return t}function c(o){return document.getElementById(o)}function i(q,p,o){if(typeof p!="object"){return q}if(q&&p){m(p,function(r,s){if(!o||typeof s!="function"){q[r]=s}})}return q}function n(s){var q=s.indexOf(".");if(q!=-1){var p=s.slice(0,q)||"*";var o=s.slice(q+1,s.length);var r=[];m(document.getElementsByTagName(p),function(){if(this.className&&this.className.indexOf(o)!=-1){r.push(this)}});return r}}function f(o){o=o||window.event;if(o.preventDefault){o.stopPropagation();o.preventDefault()}else{o.returnValue=false;o.cancelBubble=true}return false}function j(q,o,p){q[o]=q[o]||[];q[o].push(p)}function e(){return"_"+(""+Math.random()).slice(2,10)}var h=function(t,r,s){var q=this,p={},u={};q.index=r;if(typeof t=="string"){t={url:t}}i(this,t,true);m(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var v="on"+this;if(v.indexOf("*")!=-1){v=v.slice(0,v.length-1);var w="onBefore"+v.slice(2);q[w]=function(x){j(u,w,x);return q}}q[v]=function(x){j(u,v,x);return q};if(r==-1){if(q[w]){s[w]=q[w]}if(q[v]){s[v]=q[v]}}});i(this,{onCuepoint:function(x,w){if(arguments.length==1){p.embedded=[null,x];return q}if(typeof x=="number"){x=[x]}var v=e();p[v]=[x,w];if(s.isLoaded()){s._api().fp_addCuepoints(x,r,v)}return q},update:function(w){i(q,w);if(s.isLoaded()){s._api().fp_updateClip(w,r)}var v=s.getConfig();var x=(r==-1)?v.clip:v.playlist[r];i(x,w,true)},_fireEvent:function(v,y,w,A){if(v=="onLoad"){m(p,function(B,C){if(C[0]){s._api().fp_addCuepoints(C[0],r,B)}});return false}A=A||q;if(v=="onCuepoint"){var z=p[y];if(z){return z[1].call(s,A,w)}}if(y&&"onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(v)!=-1){i(A,y);if(y.metaData){if(!A.duration){A.duration=y.metaData.duration}else{A.fullDuration=y.metaData.duration}}}var x=true;m(u[v],function(){x=this.call(s,A,y,w)});return x}});if(t.onCuepoint){var o=t.onCuepoint;q.onCuepoint.apply(q,typeof o=="function"?[o]:o);delete t.onCuepoint}m(t,function(v,w){if(typeof w=="function"){j(u,v,w);delete t[v]}});if(r==-1){s.onCuepoint=this.onCuepoint}};var l=function(p,r,q,t){var o=this,s={},u=false;if(t){i(s,t)}m(r,function(v,w){if(typeof w=="function"){s[v]=w;delete r[v]}});i(this,{animate:function(y,z,x){if(!y){return o}if(typeof z=="function"){x=z;z=500}if(typeof y=="string"){var w=y;y={};y[w]=z;z=500}if(x){var v=e();s[v]=x}if(z===undefined){z=500}r=q._api().fp_animate(p,y,z,v);return o},css:function(w,x){if(x!==undefined){var v={};v[w]=x;w=v}r=q._api().fp_css(p,w);i(o,r);return o},show:function(){this.display="block";q._api().fp_showPlugin(p);return o},hide:function(){this.display="none";q._api().fp_hidePlugin(p);return o},toggle:function(){this.display=q._api().fp_togglePlugin(p);return o},fadeTo:function(y,x,w){if(typeof x=="function"){w=x;x=500}if(w){var v=e();s[v]=w}this.display=q._api().fp_fadeTo(p,y,x,v);this.opacity=y;return o},fadeIn:function(w,v){return o.fadeTo(1,w,v)},fadeOut:function(w,v){return o.fadeTo(0,w,v)},getName:function(){return p},getPlayer:function(){return q},_fireEvent:function(w,v,x){if(w=="onUpdate"){var z=q._api().fp_getPlugin(p);if(!z){return}i(o,z);delete o.methods;if(!u){m(z.methods,function(){var B=""+this;o[B]=function(){var C=[].slice.call(arguments);var D=q._api().fp_invoke(p,B,C);return D==="undefined"||D===undefined?o:D}});u=true}}var A=s[w];if(A){var y=A.apply(o,v);if(w.slice(0,1)=="_"){delete s[w]}return y}return o}})};function b(q,G,t){var w=this,v=null,D=false,u,s,F=[],y={},x={},E,r,p,C,o,A;i(w,{id:function(){return E},isLoaded:function(){return(v!==null&&v.fp_play!==undefined&&!D)},getParent:function(){return q},hide:function(H){if(H){q.style.height="0px"}if(w.isLoaded()){v.style.height="0px"}return w},show:function(){q.style.height=A+"px";if(w.isLoaded()){v.style.height=o+"px"}return w},isHidden:function(){return w.isLoaded()&&parseInt(v.style.height,10)===0},load:function(J){if(!w.isLoaded()&&w._fireEvent("onBeforeLoad")!==false){var H=function(){if(u&&!flashembed.isSupported(G.version)){q.innerHTML=""}if(J){J.cached=true;j(x,"onLoad",J)}flashembed(q,G,{config:t})};var I=0;m(a,function(){this.unload(function(K){if(++I==a.length){H()}})})}return w},unload:function(J){if(u.replace(/\s/g,"")!==""){if(w._fireEvent("onBeforeUnload")===false){if(J){J(false)}return w}D=true;try{if(v){if(v.fp_isFullscreen()){v.fp_toggleFullscreen()}v.fp_close();w._fireEvent("onUnload")}}catch(H){}var I=function(){v=null;q.innerHTML=u;D=false;if(J){J(true)}};if(/WebKit/i.test(navigator.userAgent)&&!/Chrome/i.test(navigator.userAgent)){setTimeout(I,0)}else{I()}}else{if(J){J(false)}}return w},getClip:function(H){if(H===undefined){H=C}return F[H]},getCommonClip:function(){return s},getPlaylist:function(){return F},getPlugin:function(H){var J=y[H];if(!J&&w.isLoaded()){var I=w._api().fp_getPlugin(H);if(I){J=new l(H,I,w);y[H]=J}}return J},getScreen:function(){return w.getPlugin("screen")},getControls:function(){return w.getPlugin("controls")._fireEvent("onUpdate")},getLogo:function(){try{return w.getPlugin("logo")._fireEvent("onUpdate")}catch(H){}},getPlay:function(){return w.getPlugin("play")._fireEvent("onUpdate")},getConfig:function(H){return H?k(t):t},getFlashParams:function(){return G},loadPlugin:function(K,J,M,L){if(typeof M=="function"){L=M;M={}}var I=L?e():"_";w._api().fp_loadPlugin(K,J,M,I);var H={};H[I]=L;var N=new l(K,null,w,H);y[K]=N;return N},getState:function(){return w.isLoaded()?v.fp_getState():-1},play:function(I,H){var J=function(){if(I!==undefined){w._api().fp_play(I,H)}else{w._api().fp_play()}};if(w.isLoaded()){J()}else{if(D){setTimeout(function(){w.play(I,H)},50)}else{w.load(function(){J()})}}return w},getVersion:function(){var I="flowplayer.js 3.2.11";if(w.isLoaded()){var H=v.fp_getVersion();H.push(I);return H}return I},_api:function(){if(!w.isLoaded()){throw"Flowplayer "+w.id()+" not loaded when calling an API method"}return v},setClip:function(H){m(H,function(I,J){if(typeof J=="function"){j(x,I,J);delete H[I]}else{if(I=="onCuepoint"){$f(q).getCommonClip().onCuepoint(H[I][0],H[I][1])}}});w.setPlaylist([H]);return w},getIndex:function(){return p},bufferAnimate:function(H){v.fp_bufferAnimate(H===undefined||H);return w},_swfHeight:function(){return v.clientHeight}});m(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","),function(){var H="on"+this;if(H.indexOf("*")!=-1){H=H.slice(0,H.length-1);var I="onBefore"+H.slice(2);w[I]=function(J){j(x,I,J);return w}}w[H]=function(J){j(x,H,J);return w}});m(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed,setKeyboardShortcutsEnabled,isKeyboardShortcutsEnabled").split(","),function(){var H=this;w[H]=function(J,I){if(!w.isLoaded()){return w}var K=null;if(J!==undefined&&I!==undefined){K=v["fp_"+H](J,I)}else{K=(J===undefined)?v["fp_"+H]():v["fp_"+H](J)}return K==="undefined"||K===undefined?w:K}});w._fireEvent=function(Q){if(typeof Q=="string"){Q=[Q]}var R=Q[0],O=Q[1],M=Q[2],L=Q[3],K=0;if(t.debug){g(Q)}if(!w.isLoaded()&&R=="onLoad"&&O=="player"){v=v||c(r);o=w._swfHeight();m(F,function(){this._fireEvent("onLoad")});m(y,function(S,T){T._fireEvent("onUpdate")});s._fireEvent("onLoad")}if(R=="onLoad"&&O!="player"){return}if(R=="onError"){if(typeof O=="string"||(typeof O=="number"&&typeof M=="number")){O=M;M=L}}if(R=="onContextMenu"){m(t.contextMenu[O],function(S,T){T.call(w)});return}if(R=="onPluginEvent"||R=="onBeforePluginEvent"){var H=O.name||O;var I=y[H];if(I){I._fireEvent("onUpdate",O);return I._fireEvent(M,Q.slice(3))}return}if(R=="onPlaylistReplace"){F=[];var N=0;m(O,function(){F.push(new h(this,N++,w))})}if(R=="onClipAdd"){if(O.isInStream){return}O=new h(O,M,w);F.splice(M,0,O);for(K=M+1;K<F.length;K++){F[K].index++}}var P=true;if(typeof O=="number"&&O<F.length){C=O;var J=F[O];if(J){P=J._fireEvent(R,M,L)}if(!J||P!==false){P=s._fireEvent(R,M,L,J)}}m(x[R],function(){P=this.call(w,O,M);if(this.cached){x[R].splice(K,1)}if(P===false){return false}K++});return P};function B(){if($f(q)){$f(q).getParent().innerHTML="";p=$f(q).getIndex();a[p]=w}else{a.push(w);p=a.length-1}A=parseInt(q.style.height,10)||q.clientHeight;E=q.id||"fp"+e();r=G.id||E+"_api";G.id=r;u=q.innerHTML;if(typeof t=="string"){t={clip:{url:t}}}t.playerId=E;t.clip=t.clip||{};if(q.getAttribute("href",2)&&!t.clip.url){t.clip.url=q.getAttribute("href",2)}s=new h(t.clip,-1,w);t.playlist=t.playlist||[t.clip];var I=0;m(t.playlist,function(){var L=this;if(typeof L=="object"&&L.length){L={url:""+L}}m(t.clip,function(M,N){if(N!==undefined&&L[M]===undefined&&typeof N!="function"){L[M]=N}});t.playlist[I]=L;L=new h(L,I,w);F.push(L);I++});m(t,function(L,M){if(typeof M=="function"){if(s[L]){s[L](M)}else{j(x,L,M)}delete t[L]}});m(t.plugins,function(L,M){if(M){y[L]=new l(L,M,w)}});if(!t.plugins||t.plugins.controls===undefined){y.controls=new l("controls",null,w)}y.canvas=new l("canvas",null,w);u=q.innerHTML;function K(L){if(/iPad|iPhone|iPod/i.test(navigator.userAgent)&&!/.flv$/i.test(F[0].url)&&!J()){return true}if(!w.isLoaded()&&w._fireEvent("onBeforeClick")!==false){w.load()}return f(L)}function J(){return w.hasiPadSupport&&w.hasiPadSupport()}function H(){if(u.replace(/\s/g,"")!==""){if(q.addEventListener){q.addEventListener("click",K,false)}else{if(q.attachEvent){q.attachEvent("onclick",K)}}}else{if(q.addEventListener&&!J()){q.addEventListener("click",f,false)}w.load()}}setTimeout(H,0)}if(typeof q=="string"){var z=c(q);if(!z){throw"Flowplayer cannot access element: "+q}q=z;B()}else{B()}}var a=[];function d(o){this.length=o.length;this.each=function(q){m(o,q)};this.size=function(){return o.length};var p=this;for(name in b.prototype){p[name]=function(){var q=arguments;p.each(function(){this[name].apply(this,q)})}}}window.flowplayer=window.$f=function(){var p=null;var o=arguments[0];if(!arguments.length){m(a,function(){if(this.isLoaded()){p=this;return false}});return p||a[0]}if(arguments.length==1){if(typeof o=="number"){return a[o]}else{if(o=="*"){return new d(a)}m(a,function(){if(this.id()==o.id||this.id()==o||this.getParent()==o){p=this;return false}});return p}}if(arguments.length>1){var t=arguments[1],q=(arguments.length==3)?arguments[2]:{};if(typeof t=="string"){t={src:t}}t=i({bgcolor:"#000000",version:[10,1],expressInstall:"http://releases.flowplayer.org/swf/expressinstall.swf",cachebusting:false},t);if(typeof o=="string"){if(o.indexOf(".")!=-1){var s=[];m(n(o),function(){s.push(new b(this,k(t),k(q)))});return new d(s)}else{var r=c(o);return new b(r!==null?r:k(o),k(t),k(q))}}else{if(o){return new b(o,k(t),k(q))}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.fn.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var h=document.all,j="http://get.adobe.com/flashplayer",c=typeof jQuery=="function",e=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,b={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function i(m,l){if(l){for(var f in l){if(l.hasOwnProperty(f)){m[f]=l[f]}}}return m}function a(f,n){var m=[];for(var l in f){if(f.hasOwnProperty(l)){m[l]=n(f[l])}}return m}window.flashembed=function(f,m,l){if(typeof f=="string"){f=document.getElementById(f.replace("#",""))}if(!f){return}if(typeof m=="string"){m={src:m}}return new d(f,i(i({},b),m),l)};var g=i(window.flashembed,{conf:b,getVersion:function(){var m,f;try{f=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(o){try{m=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");f=m&&m.GetVariable("$version")}catch(n){try{m=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");f=m&&m.GetVariable("$version")}catch(l){}}}f=e.exec(f);return f?[1*f[1],1*f[(f[1]*1>9?2:3)]*1]:[0,0]},asString:function(l){if(l===null||l===undefined){return null}var f=typeof l;if(f=="object"&&l.push){f="array"}switch(f){case"string":l=l.replace(new RegExp('(["\\\\])',"g"),"\\$1");l=l.replace(/^\s?(\d+\.?\d*)%/,"$1pct");return'"'+l+'"';case"array":return"["+a(l,function(o){return g.asString(o)}).join(",")+"]";case"function":return'"function()"';case"object":var m=[];for(var n in l){if(l.hasOwnProperty(n)){m.push('"'+n+'":'+g.asString(l[n]))}}return"{"+m.join(",")+"}"}return String(l).replace(/\s/g," ").replace(/\'/g,'"')},getHTML:function(o,l){o=i({},o);var n='<object width="'+o.width+'" height="'+o.height+'" id="'+o.id+'" name="'+o.id+'"';if(o.cachebusting){o.src+=((o.src.indexOf("?")!=-1?"&":"?")+Math.random())}if(o.w3c||!h){n+=' data="'+o.src+'" type="application/x-shockwave-flash"'}else{n+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}n+=">";if(o.w3c||h){n+='<param name="movie" value="'+o.src+'" />'}o.width=o.height=o.id=o.w3c=o.src=null;o.onFail=o.version=o.expressInstall=null;for(var m in o){if(o[m]){n+='<param name="'+m+'" value="'+o[m]+'" />'}}var p="";if(l){for(var f in l){if(l[f]){var q=l[f];p+=f+"="+(/function|object/.test(typeof q)?g.asString(q):q)+"&"}}p=p.slice(0,-1);n+='<param name="flashvars" value=\''+p+"' />"}n+="</object>";return n},isSupported:function(f){return k[0]>f[0]||k[0]==f[0]&&k[1]>=f[1]}});var k=g.getVersion();function d(f,n,m){if(g.isSupported(n.version)){f.innerHTML=g.getHTML(n,m)}else{if(n.expressInstall&&g.isSupported([6,65])){f.innerHTML=g.getHTML(i(n,{src:n.expressInstall}),{MMredirectURL:encodeURIComponent(location.href),MMplayerType:"PlugIn",MMdoctitle:document.title})}else{if(!f.innerHTML.replace(/\s/g,"")){f.innerHTML="<h2>Flash version "+n.version+" or greater is required</h2><h3>"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"</h3>"+(f.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+j+"'>here</a></p>");if(f.tagName=="A"||f.tagName=="DIV"){f.onclick=function(){location.href=j}}}if(n.onFail){var l=n.onFail.call(this);if(typeof l=="string"){f.innerHTML=l}}}}if(h){window[n.id]=document.getElementById(n.id)}i(this,{getRoot:function(){return f},getOptions:function(){return n},getConf:function(){return m},getApi:function(){return f.firstChild}})}if(c){jQuery.tools=jQuery.tools||{version:"3.2.11"};jQuery.tools.flashembed={conf:b};jQuery.fn.flashembed=function(l,f){return this.each(function(){$(this).data("flashembed",flashembed(this,l,f))})}}})();
@@ -0,0 +1 @@
1
+ //= require flowplayer-3.2.11.min
@@ -0,0 +1,29 @@
1
+ Gem::Specification.new do |s|
2
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
3
+
4
+ s.name = %q{c80_flowplayer}
5
+ s.version = '0.1.3.1'
6
+ s.platform = Gem::Platform::RUBY
7
+
8
+ s.authors = ["C080609A"]
9
+ s.description = %q{Flowplayer helper for Rails 4}
10
+ s.summary = %q{Flowplayer helper for Rails 4}
11
+ s.email = %q{c080609a@gmail.com}
12
+
13
+ s.date = Date.today.to_s
14
+ s.files = `git ls-files`.split("\n")
15
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
16
+ s.require_path = 'lib'
17
+
18
+ s.homepage = %q{https://github.com/c080609a/flowplayer-gem}
19
+ s.rdoc_options = ["--charset=UTF-8"]
20
+ s.required_rubygems_version = ">= 1.3.6"
21
+
22
+ s.add_development_dependency "bundler", ">= 1.0.0"
23
+ s.add_development_dependency "rspec", "~> 2.4.0"
24
+ s.add_development_dependency "nokogiri"
25
+ s.add_development_dependency "mocha"
26
+ s.add_development_dependency "rake"
27
+ s.add_dependency "json"
28
+
29
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'flowplayer'
@@ -0,0 +1,8 @@
1
+ require 'flowplayer/player'
2
+
3
+ if defined?(Rails)
4
+ #if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 1
5
+ require 'flowplayer/railties/engine'
6
+ #end
7
+ require 'flowplayer/railtie'
8
+ end
@@ -0,0 +1,98 @@
1
+ require 'json'
2
+ module Flowplayer
3
+ class Player
4
+ attr_accessor :options, :functions, :dom_id, :swf
5
+ def initialize(dom_id, swf, lib='jquery', &block)
6
+ @dom_id, @swf, @lib = dom_id, swf, lib
7
+ @options = {}
8
+ @functions = {}
9
+ block.call(self)
10
+ self
11
+ end
12
+
13
+ def to_js
14
+ json = options_to_javascript
15
+ json += functions_to_javascript
16
+ "{#{json.join(', ')}}"
17
+ end
18
+
19
+ def script_tags
20
+ final = library("flowplayer(\"#{dom_id}\", #{swf.to_json}, #{to_js});")
21
+ <<-EOS
22
+ <script type='text/javascript'>
23
+ //<![CDATA[
24
+ #{final}
25
+ //]]>
26
+ </script>
27
+ EOS
28
+ end
29
+
30
+ def library(func)
31
+ case @lib
32
+ when 'jquery'
33
+ jquery(func)
34
+ when 'prototype'
35
+ prototype(func)
36
+ end
37
+ end
38
+
39
+ def jquery(func)
40
+ <<-EOS
41
+ $(document).ready(function() {
42
+ #{func}
43
+ });
44
+ EOS
45
+ end
46
+
47
+ def prototype(func)
48
+ <<-EOS
49
+ document.observe("dom:loaded", function() {
50
+ #{func}
51
+ });
52
+ EOS
53
+ end
54
+
55
+ def only_play_button!(opts = {})
56
+ options[:plugins] ||= {}
57
+ options[:plugins][:controls] ||= {}
58
+ hash = {
59
+ :mute => false,
60
+ :slowForward => false,
61
+ :time => false,
62
+ :slowBackwards => false,
63
+ :volume => false,
64
+ :scrubber => false,
65
+ :stop => false,
66
+ :fullscreen => false,
67
+ :play => true
68
+ }
69
+ hash.merge!(opts)
70
+ options[:plugins][:controls].merge!(hash)
71
+ end
72
+
73
+
74
+ private
75
+
76
+ def functions_to_javascript
77
+ functions.map {|option, function| "\"#{option}\":#{function}"}
78
+ end
79
+
80
+ def options_to_javascript
81
+ options.map do |option, value|
82
+ "\"#{option}\":#{value.to_json}"
83
+ end
84
+ end
85
+
86
+ def method_missing(method, *args, &block)
87
+ raise "Setters are not supported use method('whatever') to set configs" if /\=$/.match(method.to_s)
88
+ if block.nil?
89
+ options[method] = args.first
90
+ else
91
+ params = block.parameters.collect {|param| param[1]}
92
+ functions[method] = "function(#{params.join(", ")}) { #{block.call.gsub(/\;$/, '')}; }"
93
+ end
94
+ return method
95
+ end
96
+
97
+ end
98
+ end
@@ -0,0 +1,14 @@
1
+ module Flowplayer
2
+ require 'rails'
3
+ require File.join(File.expand_path('../', __FILE__), 'railties/helper')
4
+ class Railtie < ::Rails::Railtie
5
+ generators do
6
+ require File.join(File.expand_path('../', __FILE__), 'railties', 'generator', 'install_generator.rb')
7
+ end
8
+ initializer "flowplayer.configure_rails_initialization" do
9
+ ActionController::Base.instance_eval do
10
+ helper Flowplayer::Helper
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ module Flowplayer
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,24 @@
1
+ module Flowplayer::Generator
2
+ class InstallGenerator < ::Rails::Generators::Base
3
+ namespace 'flowplayer'
4
+ source_root File.expand_path("../../../../../app/assets/", __FILE__)
5
+ class_option :without_asset_pipeline, :type => :boolean, :default => false, :desc => "Place assets in public folder"
6
+ argument :install_type, :type => :string, :banner => "commercial", :required => false, :default => ''
7
+
8
+ def install_flowplayer
9
+ if options[:without_asset_pipeline]
10
+ copy_file 'javascripts/flowplayer-3.2.11.min.js', Rails.root.join("public", 'javascripts', 'flowplayer.min.js')
11
+ end
12
+ end
13
+
14
+ def install_swfs
15
+ if install_type == 'commercial'
16
+ copy_file 'flash/flowplayer.commercial-3.2.15.swf', Rails.root.join('public', 'flowplayer.swf')
17
+ else
18
+ copy_file 'flash/flowplayer-3.2.15.swf', Rails.root.join('public', 'flowplayer.swf')
19
+ copy_file '../../FLOWPLAYER_LICENSE.txt', Rails.root.join('FLOWPLAYER_LICENSE.txt')
20
+ end
21
+ copy_file 'flash/flowplayer.controls-3.2.14.swf', Rails.root.join('public', 'flowplayer.controls.swf')
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ module Flowplayer
2
+ module Helper
3
+
4
+ # flowplayer_for :hubble do |f|
5
+ # f.option 'foo'
6
+ # f.onLoad do
7
+ # 'this.unmute();'
8
+ # end
9
+ # f.onStart do |clip|
10
+ # 'alert(clip.metaData.width);'
11
+ # end
12
+
13
+ def flowplayer_for(id, swf, lib='jquery', &block)
14
+ Player.new(id, swf, lib, &block).script_tags.html_safe
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+
3
+ describe Flowplayer::Player do
4
+ it "should set options from block" do
5
+ flow_player = Flowplayer::Player.new('my_video', 'commericial.swf') do |player|
6
+ player.fullscreen true
7
+ player.logo(:url => nil, :opacity => 0, :fullscreenOnly => true)
8
+ player.onLoad do
9
+ 'this.unmute();'
10
+ end
11
+ player.onStart do |clip|
12
+ 'alert(clip.metaData.width);'
13
+ end
14
+ end
15
+
16
+ flow_player.options[:fullscreen].should == true
17
+ flow_player.functions[:onLoad].should == 'function() { this.unmute(); }'
18
+ flow_player.functions[:onStart].should == 'function(clip) { alert(clip.metaData.width); }'
19
+ flow_player.options[:logo].should be_an(Hash)
20
+
21
+ end
22
+
23
+ it "should set the dom_id to 'my_video'" do
24
+ flow_player = Flowplayer::Player.new('my_video', 'commericial.swf') do |player|
25
+ player.fullscreen true
26
+ end
27
+ flow_player.dom_id.should == 'my_video'
28
+ end
29
+
30
+ it "should generate valid options" do
31
+ flow_player = Flowplayer::Player.new('my_video', 'commericial.swf') do |player|
32
+ player.fullscreen true
33
+ player.logo({:opacity => 0, :fullscreenOnly => true})
34
+ player.onLoad do
35
+ 'this.unmute();'
36
+ end
37
+ end
38
+ flow_player.to_js.should include 'fullscreen'
39
+ flow_player.to_js.should match /^\{.+\}$/
40
+ flow_player.to_js.should include({:opacity => 0, :fullscreenOnly => true}.to_json)
41
+ end
42
+
43
+ it "should create script tags with options" do
44
+ flow_player = Flowplayer::Player.new('my_video', 'commericial.swf') do |player|
45
+ player.fullscreen true
46
+ player.logo(:url => nil, :opacity => 0, :fullscreenOnly => true)
47
+ player.onLoad do
48
+ 'this.unmute();'
49
+ end
50
+ end
51
+ ["<script", "</script>", "flowplayer(\"my_video\", \"commericial.swf\", #{flow_player.to_js}"].each do |part|
52
+ flow_player.script_tags.should include part
53
+ end
54
+ flow_player.script_tags.should match(/\)\;/)
55
+ end
56
+
57
+ it "should raise exception if passed a setter" do
58
+ lambda do
59
+ flow_player = Flowplayer::Player.new('my_video', 'commericial.swf') do |player|
60
+ player.fullscreen = true
61
+ end
62
+ end.should raise_error
63
+ end
64
+
65
+ it "should support jquery" do
66
+ flow_player = Flowplayer::Player.new('my_video', 'commericial.swf') do |player|
67
+ player.fullscreen true
68
+ player.logo(:url => nil, :opacity => 0, :fullscreenOnly => true)
69
+ end
70
+ flow_player.should include('$(document).ready(function(){')
71
+ end
72
+
73
+ it "should support prototype" do
74
+ flow_player = Flowplayer::Player.new('my_video', 'commericial.swf', 'prototype') do |player|
75
+ player.fullscreen true
76
+ player.logo(:url => nil, :opacity => 0, :fullscreenOnly => true)
77
+ end
78
+ flow_player.should include('document.observe(function(){')
79
+ end
80
+ end
@@ -0,0 +1,29 @@
1
+ class String
2
+ def html_safe
3
+ self
4
+ end
5
+ end
6
+ describe Flowplayer::Helper do
7
+ include Flowplayer::Helper
8
+
9
+
10
+
11
+ it "should render player" do
12
+ flow_player = flowplayer_for('my_video', 'commericial.swf') do |player|
13
+ player.fullscreen true
14
+ player.logo(:url => nil, :opacity => 0, :fullscreenOnly => true)
15
+ end
16
+ flow_player.should include('$(document).ready(function() {')
17
+ end
18
+
19
+
20
+
21
+ it "should support prototype" do
22
+ flow_player = flowplayer_for('my_video', 'commericial.swf', 'prototype') do |player|
23
+ player.fullscreen true
24
+ player.logo(:url => nil, :opacity => 0, :fullscreenOnly => true)
25
+ end
26
+ flow_player.should include('document.observe("dom:loaded", function() {')
27
+ end
28
+
29
+ end
@@ -0,0 +1,2 @@
1
+ require File.expand_path('../../lib/flowplayer', __FILE__)
2
+ require 'flowplayer/railties/helper'
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: c80_flowplayer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3.1
5
+ platform: ruby
6
+ authors:
7
+ - C080609A
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.4.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.4.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mocha
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Flowplayer helper for Rails 4
98
+ email: c080609a@gmail.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - ".gitignore"
104
+ - ".rspec"
105
+ - ".travis.yml"
106
+ - FLOWPLAYER_LICENSE.txt
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - LICENSE.txt
110
+ - README.mdown
111
+ - README.txt
112
+ - Rakefile
113
+ - app/assets/flash/flowplayer-3.2.15.swf
114
+ - app/assets/flash/flowplayer.commercial-3.2.15.swf
115
+ - app/assets/flash/flowplayer.controls-3.2.14.swf
116
+ - app/assets/javascripts/flowplayer-3.2.11.min.js
117
+ - app/assets/javascripts/flowplayer.min.js
118
+ - flowplayer.gemspec
119
+ - init.rb
120
+ - lib/flowplayer.rb
121
+ - lib/flowplayer/player.rb
122
+ - lib/flowplayer/railtie.rb
123
+ - lib/flowplayer/railties/engine.rb
124
+ - lib/flowplayer/railties/generator/install_generator.rb
125
+ - lib/flowplayer/railties/helper.rb
126
+ - spec/flowplayer_spec.rb
127
+ - spec/rails_helper_spec.rb
128
+ - spec/spec_helper.rb
129
+ homepage: https://github.com/c080609a/flowplayer-gem
130
+ licenses: []
131
+ metadata: {}
132
+ post_install_message:
133
+ rdoc_options:
134
+ - "--charset=UTF-8"
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: 1.3.6
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.4.7
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Flowplayer helper for Rails 4
153
+ test_files: []