/* * 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'}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")+"

"+(m.tagName=="A"?"

Click here to download latest version

":"

Download latest version from here

");if(m.tagName=="A"){m.onclick=function(){location.href="http://www.adobe.com/go/getflashplayer" rel="nofollow"}}}}}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="vsm;" 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);