1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-06 06:50:51 +02:00
video.js/tech/flowplayer.js

153 lines
19 KiB
JavaScript
Raw Normal View History

2011-10-01 03:28:43 +03:00
// Flowplayer API Connector
VideoJS.tech.flowplayer = {
name: "Flowplayer",
2011-10-01 03:28:43 +03:00
supported: function(){
if (flowplayer) {
return true;
} else {
return false;
}
},
canPlaySource: function(sourceObj){
if (sourceObj.type in _V_.tech.flowplayer.supports.format) { return "maybe"; }
},
supports: {
format: {
"video/flv": "FLV",
"video/x-flv": "FLV",
"video/mp4": "MP4",
"video/m4v": "MP4"
},
// Optional events that we can manually mimic with timers
event: {
progress: false,
timeupdate: false
}
},
init: function(sourceObj){
var player = this;
flowplayer(
this.box.id, // Where it will put the swf object inside of
{
src: 'http://releases.flowplayer.org/swf/flowplayer-3.2.5.swf',
wmode: 'opaque'
},
{
2011-10-01 03:28:43 +03:00
clip: {
url: sourceObj.src,
autoPlay: false,
scaling: "fit",
onBegin: _V_.proxy(this, function(){
this.triggerEvent("loadstart");
})
},
autoPlay: true,
onLoad: function() {
player.tels.flowplayer = document.getElementById(player.box.id+"_api");
player.tels.flowplayer.className = "vjs-tech";
player.tels.flowplayer.api = this; // Need to re-establish API on object
player.triggerEvent("techready");
},
// Hide Flowplayer's big play button
play: {opacity: 0},
// Hide Flowplayer's controls
plugins: { controls: { autoHide: "always" } },
2011-10-01 03:28:43 +03:00
plugins: { controls: null }
}
);
},
api: {
setupTriggers: function(){
2011-10-01 03:28:43 +03:00
// Map flowplayer events to video.js events
var map = [
{ f:"onStart", v:"play" },
{ f:"onResume", v:"play" },
{ f:"onPause", v:"pause" },
{ f:"onVolume", v:"volumechange" },
{ f:"onError", v:"error" }
];
_V_.each(map, _V_.proxy(this, function(item){
this.tels.flowplayer.api[item.f](_V_.proxy(this, function(e){ this.triggerEvent(item.v, e); }));
}));
},
2011-10-01 03:28:43 +03:00
play: function(){ this.tels.flowplayer.api.play(); },
pause: function(){ this.tels.flowplayer.api.pause(); },
paused: function(){
2011-10-01 03:28:43 +03:00
return !this.tels.flowplayer.api.isPlaying(); // More accurate than isPaused
},
2011-10-01 03:28:43 +03:00
currentTime: function(){ return this.tels.flowplayer.api.getTime(); },
setCurrentTime: function(seconds){ this.tels.flowplayer.api.seek(seconds); },
duration: function(){
2011-10-01 03:28:43 +03:00
var clip = this.tels.flowplayer.api.getClip();
return (clip) ? clip.duration : 0;
},
buffered: function(){
2011-10-01 03:28:43 +03:00
var status = this.tels.flowplayer.api.getStatus();
return _V_.createTimeRange(status.bufferStart, status.bufferEnd);
},
2011-10-01 03:28:43 +03:00
volume: function(){ return _V_.round(this.tels.flowplayer.api.getVolume() / 100, 2); },
setVolume: function(percentAsDecimal){ this.tels.flowplayer.api.setVolume(parseInt(percentAsDecimal * 100)); },
muted: function(){ return this.volume() == 0; },
setMuted: function(bool){
if (bool) {
this.values.mutedVol = this.volume();
this.volume(0);
} else {
this.volume(this.values.mutedVol);
}
},
supportsFullScreen: function(){
return false; // Flash does not allow fullscreen through javascript
// Maybe at click listener, and say "click screen".
},
2011-10-01 03:28:43 +03:00
enterFullScreen: function(){ this.tels.flowplayer.api.toggleFullscreen(); },
readError: function(eventArguments){
var errorCode = arguments[0],
errorMessage = arguments[1];
return errorMessage;
2011-10-01 03:28:43 +03:00
},
src: function(src){
this.setClip(src);
},
load: function(){
// Flowplayer always auto loads
}
}
};
2011-10-01 03:28:43 +03:00
/*
* flowplayer.js 3.2.4. The Flowplayer API
*
* Copyright 2009 Flowplayer Oy
*
* This file is part of Flowplayer.
*
* Flowplayer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Flowplayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Flowplayer. If not, see <http://www.gnu.org/licenses/>.
*
* Date: 2010-08-25 12:48:46 +0000 (Wed, 25 Aug 2010)
* Revision: 551
*/
2011-10-01 03:28:43 +03:00
(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="