/*
* flowplayer.js 3.2.6. the flowplayer api
*
* copyright 2009-2011 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 .
*
* date: 2011-02-04 05:45:28 -0500 (fri, 04 feb 2011)
* revision: 614
*/
(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];p1){var t=arguments[1],q=(arguments.length==3)?arguments[2]:{};if(typeof t=="string"){t={src:t}}t=i({bgcolor:"#000000",version:[9,0],expressinstall:"http://static.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:o,t,q)}}else{if(o){return new b(o,t,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 e=typeof jquery=="function";var i={width:"100%",height:"100%",allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:null,onfail:null,expressinstall:null,w3c:false,cachebusting:false};if(e){jquery.tools=jquery.tools||{};jquery.tools.flashembed={version:"1.0.4",conf:i}}function j(){if(c.done){return false}var l=document;if(l&&l.getelementsbytagname&&l.getelementbyid&&l.body){clearinterval(c.timer);c.timer=null;for(var k=0;k";if(q.w3c||s){n+=''}q.width=q.height=q.id=q.w3c=q.src=null;for(var l in q){if(q[l]!==null){n+=''}}var o="";if(t){for(var m in t){if(t[m]!==null){o+=m+"="+(typeof t[m]=="object"?g(t[m]):t[m])+"&"}}o=o.substring(0,o.length-1);n+='"}n+="";return n}function d(m,p,l){var k=flashembed.getversion();f(this,{getcontainer:function(){return m},getconf:function(){return p},getversion:function(){return k},getflashvars:function(){return l},getapi:function(){return m.firstchild},gethtml:function(){return a(p,l)}});var q=p.version;var r=p.expressinstall;var o=!q||flashembed.issupported(q);if(o){p.onfail=p.version=p.expressinstall=null;m.innerhtml=a(p,l)}else{if(q&&r&&flashembed.issupported([6,65])){f(p,{src:r});l={mmredirecturl:location.href,mmplayertype:"plugin",mmdoctitle:document.title};m.innerhtml=a(p,l)}else{if(m.innerhtml.replace(/\s/g,"")!==""){}else{m.innerhtml="
flash version "+q+" or greater is required
"+(k[0]>0?"your version is "+k:"you have no flash plugin installed")+"
");if(m.tagname=="a"){m.onclick=function(){location.href="http://www.adobe.com/go/getflashplayer"}}}}}if(!o&&p.onfail){var n=p.onfail.call(this);if(typeof n=="string"){m.innerhtml=n}}if(document.all){window[p.id]=document.getelementbyid(p.id)}}window.flashembed=function(l,m,k){if(typeof l=="string"){var n=document.getelementbyid(l);if(n){l=n}else{c(function(){flashembed(l,m,k)});return}}if(!l){return}if(typeof m=="string"){m={src:m}}var o=f({},i);f(o,m);return new d(l,o,k)};f(window.flashembed,{getversion:function(){var m=[0,0];if(navigator.plugins&&typeof navigator.plugins["shockwave flash"]=="object"){var l=navigator.plugins["shockwave flash"].description;if(typeof l!="undefined"){l=l.replace(/^.*\s+(\s+\s+\s+$)/,"$1");var n=parseint(l.replace(/^(.*)\..*$/,"$1"),10);var r=/r/.test(l)?parseint(l.replace(/^.*r(.*)$/,"$1"),10):0;m=[n,r]}}else{if(window.activexobject){try{var p=new activexobject("shockwaveflash.shockwaveflash.7")}catch(q){try{p=new activexobject("shockwaveflash.shockwaveflash.6");m=[6,0];p.allowscriptaccess="always"}catch(k){if(m[0]==6){return m}}try{p=new activexobject("shockwaveflash.shockwaveflash")}catch(o){}}if(typeof p=="object"){l=p.getvariable("$version");if(typeof l!="undefined"){l=l.replace(/^\s+\s+(.*)$/,"$1").split(",");m=[parseint(l[0],10),parseint(l[2],10)]}}}}return m},issupported:function(k){var m=flashembed.getversion();var l=(m[0]>k[0])||(m[0]==k[0]&&m[1]>=k[1]);return l},domready:c,asstring:g,gethtml:a});if(e){jquery.fn.flashembed=function(l,k){var m=null;this.each(function(){m=flashembed(this,l,k)});return l.api===false?this:m}}})();
(function(){
var domready = window.domready = {};
// everything that has to do with properly supporting our document ready event. brought over from the most awesome jquery.
var useragent = navigator.useragent.tolowercase();
// figure out what browser is being used
var browser = {
version: (useragent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
safari: /webkit/.test(useragent),
opera: /opera/.test(useragent),
msie: (/msie/.test(useragent)) && (!/opera/.test( useragent )),
mozilla: (/mozilla/.test(useragent)) && (!/(compatible|webkit)/.test(useragent))
};
var readybound = false;
var isready = false;
var readylist = [];
// handle when the dom is ready
function domready() {
// make sure that the dom is not already loaded
if(!isready) {
// remember that the dom is ready
isready = true;
if(readylist) {
for(var fn = 0; fn < readylist.length; fn++) {
readylist[fn].call(window, []);
}
readylist = [];
}
}
};
// from simon willison. a safe way to fire onload w/o screwing up everyone else.
function addloadevent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
};
// does the heavy work of working through the browsers idiosyncracies (let's call them that) to hook onload.
function bindready() {
if(readybound) {
return;
}
readybound = true;
// mozilla, opera (see further below for it) and webkit nightlies currently support this event
if (document.addeventlistener && !browser.opera) {
// use the handy event callback
document.addeventlistener("domcontentloaded", domready, false);
}
// if ie is used and is not in a frame
// continually check to see if the document is ready
if (browser.msie && window == top) (function(){
if (isready) return;
try {
// if ie is used, use the trick by diego perini
// http://javascript.nwbox.com/iecontentloaded/
document.documentelement.doscroll("left");
} catch(error) {
settimeout(arguments.callee, 0);
return;
}
// and execute any waiting functions
domready();
})();
if(browser.opera) {
document.addeventlistener( "domcontentloaded", function () {
if (isready) return;
for (var i = 0; i < document.stylesheets.length; i++)
if (document.stylesheets[i].disabled) {
settimeout( arguments.callee, 0 );
return;
}
// and execute any waiting functions
domready();
}, false);
}
if(browser.safari) {
var numstyles;
(function(){
if (isready) return;
if (document.readystate != "loaded" && document.readystate != "complete") {
settimeout( arguments.callee, 0 );
return;
}
if (numstyles === undefined) {
var links = document.getelementsbytagname("link");
for (var i=0; i < links.length; i++) {
if(links[i].getattribute('rel') == 'stylesheet') {
numstyles++;
}
}
var styles = document.getelementsbytagname("style");
numstyles += styles.length;
}
if (document.stylesheets.length != numstyles) {
settimeout( arguments.callee, 0 );
return;
}
// and execute any waiting functions
domready();
})();
}
// a fallback to window.onload, that will always work
addloadevent(domready);
};
// this is the public function that people can use to hook up ready.
domready.ready = function(fn, args) {
// attach the listeners
bindready();
// if the dom is already ready
if (isready) {
// execute the function immediately
fn.call(window, []);
} else {
// add the function to the wait list
readylist.push( function() { return fn.call(window, []); } );
}
};
bindready();
})();
/*
* html 5 media compatibility layer.
*
* copyright 2010 dave hall .
*
* this script is part of the html5media project. the html5media project enables
* html5 video and audio tags in all major browsers.
*
* the html5media project 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.
*
* the html5media project 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 html5media. if not, see.
*
* developed by dave hall.
*
*
*/
(function(window, document, undefined) {
"use strict";
// tagnames for the different types of media tag.
var video_tag = "video";
var audio_tag = "audio";
// if no video tag is supported, go ahead and enable all html5 elements.
if (!document.createelement(video_tag).canplaytype) {
document.createelement(audio_tag);
document.createelement("source");
}
// checks whether this is a broken android implementation.
var isbrokenandroid = window.navigator.useragent.tolowercase().match(/android 2\.[12]/) !== null;
// checks if this is opera.
var isopera = window.navigator.useragent.tolowercase().match(/opera/) !== null;
// checks whether the given element can play the fiven format.
function canplayformat(element, format) {
return element.canplaytype(format) || (isbrokenandroid && format.search("mp4") > -1);
}
//swf播放器
function swfplay(element, url){
var replacement = document.createelement("span");
replacement.id = element.id;
replacement.style.csstext = element.style.csstext;
replacement.classname = element.classname +" video-play-wrapper-swf";
replacement.title = element.title;
replacement.style.display = "block";
replacement.style.width = getdimension(element, "width", "300px");
replacement.innerhtml = "";
// replace the element with the div.
element.parentnode.replacechild(replacement, element);
}
// scans over elements with the given tag name, creating fallbacks if required.
function scanelementsbytagname(tagname) {
var elements = document.getelementsbytagname(tagname);
var elementslist = [];
for (var n = 0; n < elements.length; n++) {
elementslist.push(elements[n]);
}
for (n = 0; n < elementslist.length; n++) {
var element = elementslist[n];
var requiresfallback = true;
var createswfplay = false; //是否用swf播放
var videourl = "";
// test if the media tag is supported.
if (element.canplaytype) {
// if the media has a src attribute, and can play it, then all is good.
if (element.src) {
if ( canplayformat(element, guessformat(tagname, element.src)) && !(element.src.search(/.flv/i) > 0) ) { //增加是否是flv格式视频的判断
if( element.src.search(/.swf/i) > 0 ){
requiresfallback = false;
createswfplay = true;
videourl = element.src;
}else{
requiresfallback = false;
createswfplay = false;
}
}
} else {
// check for source child attributes.
var sources = element.getelementsbytagname("source");
for (var m = 0; m < sources.length; m++) {
var source = sources[m];
if ( canplayformat(element, guessformat(tagname, source.src, source.type)) && !(source.src.search(/.flv/i) > 0) ) { //增加是否是flv格式视频的判
if( source.src.search(/.swf/i) > 0 ){
requiresfallback = false;
createswfplay = true;
videourl = source.src;
break;
}else{
requiresfallback = false;
createswfplay = false;
break;
}
}
}
}
}else{
//不支持html5标签
if (element.src) {
if( element.src.search(/.swf/i) > 0 ){
requiresfallback = false;
createswfplay = true;
videourl = element.src;
}else{
createswfplay = false;
}
} else {
// check for source child attributes.
var sources = element.getelementsbytagname("source");
for (var m = 0; m < sources.length; m++) {
var source = sources[m];
if( source.src.search(/.swf/i) > 0 ){
requiresfallback = false;
createswfplay = true;
videourl = source.src;
break;
}else{
createswfplay = false;
break;
}
}
}
}
//使用swf播放视频
if( createswfplay ){
swfplay(element, videourl);
}
// if cannot play media, create the fallback. 是否使用flowplay播放视频判断
if (requiresfallback || html5media.forcefallback(tagname, element)) {
html5media.createfallback(tagname, element);
} else {
// hack: enables playback in android mobile.
if (isbrokenandroid) {
element.addeventlistener("click", function() {
this.play();
}, false);
}
}
}
}
/**
* replaces all video tags with flowplayer video player if the browser does
* not support either the video tag the h.264 codex.
*
* this is run automatically on document ready, but can be run manually
* again after dynamically creating html5 video tags.
*/
function html5media() {
scanelementsbytagname("video");
scanelementsbytagname("audio");
}
/**
* callback to allow conditional forcing of the fallback player.
*
* return true to force the flash fallback. the default implementation never
* forces the flash fallback.
*/
html5media.forcefallback = function(tagname, element) {
return false;
};
// removes the final filename from the given path.
function dirname(path) {
return path.split("/").slice(0, -1).join("/") + "/";
}
/**
* the locations of the flowplayer and flowplayer controls swf files.
*
* override this if they are not located in the same folder as the
*/
var scriptroot = (function() {
var scripts = document.getelementsbytagname("script");
for (var n = 0; n < scripts.length; n++) {
var script = scripts[n];
if (script.src.match(/html5media(\.min|)\.js/)) {
return dirname(script.src);
}
}
return "";
}());
html5media.flowplayerswf = scriptroot + "flowplayer.swf";
html5media.flowplayeraudioswf = scriptroot + "flowplayer.audio.swf";
html5media.flowplayercontrolsswf = scriptroot + "flowplayer.controls.swf";
html5media.expressinstallswf = scriptroot + "expressinstall.swf";
// known media formats.
var theora_format = 'video/ogg; codecs="theora, vorbis"';
var h264_format = 'video/mp4; codecs="avc1.42e01e, mp4a.40.2"';
var vorbis_format = 'audio/ogg; codecs="vorbis"';
var webm_format = 'video/webm;';
var m4a_format = 'audio/x-m4a;';
var mp3_format = 'audio/mpeg;';
var wav_format = 'audio/wav; codecs="1"';
/**
* the video format to assume if it cannot be determined what format a media
* file is.
*/
var assumedformats = {
video: h264_format,
audio: mp3_format
};
/**
* formats that the fallback flash player is able to understand.
*/
var fallbackformats = [h264_format, m4a_format, mp3_format];
/**
* known file extensions that can be used to guess media formats in the
* absence of other information.
*/
var fileextensions = {
video: {
"ogg": theora_format,
"ogv": theora_format,
"avi": h264_format,
"mp4": h264_format,
"mkv": h264_format,
"h264": h264_format,
"264": h264_format,
"avc": h264_format,
"m4v": h264_format,
"3gp": h264_format,
"3gpp": h264_format,
"3g2": h264_format,
"mpg": h264_format,
"mpeg": h264_format,
"webm": webm_format
},
audio: {
"ogg": vorbis_format,
"oga": vorbis_format,
"aac": m4a_format,
"m4a": m4a_format,
"mp3": mp3_format,
"wav": wav_format
}
};
// trys to determine the format of a given video file.
function guessformat(tag, src, type) {
// an explicit type is always best.
if (type) {
return type;
}
// try to match based on file extension.
var extensionmatch = (/\.([a-z1-9]+)(\?|#|\s|$)/i).exec(src);
if (extensionmatch) {
var format = fileextensions[tag][extensionmatch[1]];
if (format) {
return format;
}
}
return assumedformats[tag];
}
// detects presence of html5 attributes.
function hasattr(element, attr) {
var val = element.getattribute(attr);
return !!val || typeof val == "string";
}
// standardizes urls to avoid confusing flowplayer.
function fixpath(url) {
var link = document.createelement("a");
link.href = url;
return link.href;
}
// calculates the given dimension of the given element.
function getdimension(element, dimension, fallback) {
// attempt to use it's attribute value.
var result = element.getattribute(dimension);
if (result) {
return result + "px";
}
// attempt to use it's computed style.
var style;
if (element.currentstyle) {
style = element.currentstyle[dimension];
} else if (window.getcomputedstyle) {
style = document.defaultview.getcomputedstyle(element, null).getpropertyvalue(dimension);
} else {
return fallback;
}
if (style == "auto") {
return fallback;
}
return style;
}
// extracts the mimetype from a format string.
function getmimetype(format) {
return format.match(/\s*([\w-]+\/[\w-]+)(;|\s|$)/)[1];
}
// checks whether the two formats are equivalent.
function formatmatches(format1, format2) {
return (getmimetype(format1) == getmimetype(format2));
}
/**
* callback for adding custom configuration options to flowplayer before it
* launches. this callback is supplied with the tagname of the element being
* replaced ("video" or "audio"), the element being replaced, and the
* generated flowplayer configuration.
*
* this callback should return the updated flowplayer configuration. by
* the default implementation leaves the generated configuration intact.
*/
html5media.configureflowplayer = function(element, config) {
return config;
};
/**
* default callback for creating a fallback for html5 media tags.
*
* this implementation creates flowplayer instances, but this can
* theoretically be used to support all different types of flash player.
*/
html5media.createfallback = function(tagname, element) {
var hascontrols = hasattr(element, "controls");
// standardize the src and poster.
var poster = element.getattribute("poster") || "";
var src = element.getattribute("src") || "";
if (!src) {
// find a compatible fallback file.
var sources = element.getelementsbytagname("source");
for (var sn = 0; sn < sources.length; sn++) {
var source = sources[sn];
var srcvalue = source.getattribute("src");
if (srcvalue) {
for (var fn = 0; fn < fallbackformats.length; fn++) {
var fallbackformat = fallbackformats[fn];
if (formatmatches(fallbackformat, guessformat(tagname, srcvalue, source.getattribute("type")))) {
src = srcvalue;
break;
}
}
}
if (src) {
break;
}
}
}
// if there is no src, then fail silently for now.
if (!src) {
return;
}
// create the replacement element div.
var replacement = document.createelement("span");
replacement.id = element.id;
replacement.style.csstext = element.style.csstext;
replacement.classname = element.classname;
replacement.title = element.title;
replacement.style.display = "block";
replacement.style.width = getdimension(element, "width", "300px");
if (tagname == "audio") {
replacement.style.height = "26px";
} else {
replacement.style.height = getdimension(element, "height", "200px");
}
// replace the element with the div.
element.parentnode.replacechild(replacement, element);
var preload = (element.getattribute("preload") || "").tolowercase();
// activate flowplayer.
var playlist = [];
if (poster) {
playlist.push({url: fixpath(poster)});
}
if (src) {
playlist.push({
url: fixpath(src),
autoplay: hasattr(element, "autoplay"),
autobuffering: hasattr(element, "autobuffer") || (hasattr(element, "preload") && (preload === "" || preload == "auto")),
onbeforefinish: function() {
return !hasattr(element, "loop");
}
});
}
// determine which plugins should be loaded.
var plugins = {
controls: hascontrols && {
url: fixpath(html5media.flowplayercontrolsswf),
opacity: 0.8,
backgroundcolor: "#181818",
backgroundgradient: "none",
fullscreen: tagname == video_tag,
autohide: tagname == video_tag && {
fullscreenonly: false,
enabled: true,
hidestyle: "fade",
mouseoutdelay: 0
} || {
enabled: false
}
} || null
};
// hack: opera cannot autohide controls, for some reason.
if (isopera && plugins.controls) {
plugins.controls.autohide.enabled = false;
}
// audio-specific config.
if (tagname == "audio") {
// load the audio plugin.
plugins.audio = {
url: fixpath(html5media.flowplayeraudioswf)
};
// hack: the flowplayer audio plugin requires that the controls plugin is present.
if (!hascontrols) {
plugins.controls = {
url: fixpath(html5media.flowplayercontrolsswf),
display: "none"
};
replacement.style.height = 0;
}
// hack: disable autobuffering, since a flowplayer audio bug can cause uncontrollable autoplaying.
playlist[playlist.length - 1].autobuffering = false;
}
// load the flowplayer.
var config = {
play: null,
playlist: playlist,
clip: {
scaling: "fit",
fadeinspeed: 0,
fadeoutspeed: 0
},
canvas: {
backgroundgradient: "none",
backgroundcolor: "#000000"
},
plugins: plugins
};
config = html5media.configureflowplayer(element, config);
flowplayer(replacement, {
src: fixpath(html5media.flowplayerswf),
expressinstall: fixpath(html5media.expressinstallswf),
wmode: "opaque"
}, config);
};
// automatically execute the html5media function on page load.
domready.ready(html5media);
// expose html5media to the global object.
window.html5media = html5media;
})(this, document);