Changeset 1308


Ignore:
Timestamp:
09/21/10 21:29:37 (3 years ago)
Author:
pablo
Message:

Fixes some issues with video tag parsing in IE

Location:
trunk/js
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/js/bin-debug/jwplayer.js

    r1290 r1308  
    212212                        // IE6/7/8 case 
    213213                        var currentElement = domElement.nextSibling; 
    214                         if (currentElement[0] !== undefined){ 
    215                                 while(currentElement[0].tagName.toLowerCase() == "source") { 
    216                                         sources.push(parseSourceElement(currentElement[0])); 
     214                        if (currentElement !== undefined){ 
     215                                while(currentElement.tagName.toLowerCase() == "source") { 
     216                                        sources.push(parseSourceElement(currentElement)); 
    217217                                        currentElement = currentElement.nextSibling; 
    218218                                }                                
     
    738738                                        } else { 
    739739                                                this.players.splice(0, 1); 
    740                                                 this.embedPlayer(); 
     740                                                return this.embedPlayer(); 
     741                                                 
    741742                                        } 
    742743                                        break; 
     
    748749                                        } else { 
    749750                                                this.players.splice(0, 1); 
    750                                                 this.embedPlayer(); 
     751                                                return this.embedPlayer(); 
    751752                                        } 
    752753                                        break; 
     
    762763 
    763764                setupEvents : function() { 
    764                         for (event in this.events) { 
    765                                 if (typeof this.api[event] == "function") { 
    766                                         (this.api[event]).call(this.api, this.events[event]); 
     765                        for (evt in this.events) { 
     766                                if (typeof this.api[evt] == "function") { 
     767                                        (this.api[evt]).call(this.api, this.events[evt]); 
    767768                                } 
    768769                        } 
     
    775776                                } else if (loadParams.levels) { 
    776777                                        var item = this.getPlaylistItem(0); 
    777                                         console.log("Item: %o", item); 
    778778                                        if (!item) { 
    779                                                 item = { file: loadParams.levels[0].file }; 
     779                                                item = { file: loadParams.levels[0].file, provider:'video' }; 
    780780                                        } 
    781781                                        if (!item.image) { 
  • trunk/js/jwplayer.min.js

    r1290 r1308  
    1 jwplayer=function(a){return jwplayer.constructor(a)};jwplayer.constructor=function(a){};$jw=jwplayer;jwplayer.utils=function(){};jwplayer.utils.typeOf=function(b){var a=typeof b;if(a==="object"){if(b){if(b instanceof Array){a="array"}}else{a="null"}}return a};jwplayer.utils.extend=function(){var a=jwplayer.utils.extend["arguments"];if(a.length>1){for(var b=1;b<a.length;b++){for(element in a[b]){a[0][element]=a[b][element]}}return a[0]}return null};jwplayer.utils.html=function(a,b){a.innerHTML=b};jwplayer.utils.append=function(a,b){a.appendChild(b)};jwplayer.utils.wrap=function(a,b){a.parentNode.replaceChild(b,a);b.appendChild(a)};jwplayer.utils.ajax=function(d,c,a){var b;if(window.XMLHttpRequest){b=new XMLHttpRequest()}else{b=new ActiveXObject("Microsoft.XMLHTTP")}b.onreadystatechange=function(){if(b.readyState===4&&b.status===200){if(c){c(b)}}else{if(a){a(d)}}};b.open("GET",d,true);b.send();return b};jwplayer.utils.load=function(b,c,a){b.onreadystatechange=function(){if(b.readyState===4){if(b.status===200){if(c){c()}}else{if(a){a()}}}}};jwplayer.utils.find=function(b,a){return b.getElementsByTagName(a)};jwplayer.utils.append=function(a,b){a.appendChild(b)};jwplayer.utils.isIE=function(){return(!+"\v1")};jwplayer.utils.hasHTML5=function(){return !!document.createElement("video").canPlayType};jwplayer.utils.hasFlash=function(){return(typeof navigator.plugins!="undefined"&&typeof navigator.plugins["Shockwave Flash"]!="undefined")||(typeof window.ActiveXObject!="undefined")};(function(e){e.utils.mediaparser=function(){};var g={element:{width:"width",height:"height",id:"id","class":"className",name:"name"},media:{src:"file",preload:"preload",autoplay:"autostart",loop:"repeat",controls:"controls"},source:{src:"file",type:"type",media:"media","data-jw-width":"width","data-jw-bitrate":"bitrate"},video:{poster:"image"}};var f={};e.utils.mediaparser.parseMedia=function(i){return d(i)};function c(j,i){if(i===undefined){i=g[j]}else{e.utils.extend(i,g[j])}return i}function d(m,i){if(f[m.tagName.toLowerCase()]&&(i===undefined)){return f[m.tagName.toLowerCase()](m)}else{i=c("element",i);var n={};for(var j in i){if(j!="length"){var l=m.getAttribute(j);if(!(l===""||l===undefined||l===null)){n[i[j]]=m.getAttribute(j)}}}var k=m.style["#background-color"];if(k&&!(k=="transparent"||k=="rgba(0, 0, 0, 0)")){n.screencolor=k}return n}}function h(o,k){k=c("media",k);var m=[];if(!(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length)){var l=o.nextSibling;if(l[0]!==undefined){while(l[0].tagName.toLowerCase()=="source"){m.push(a(l[0]));l=l.nextSibling}}}else{var j=e.utils.selectors("source",o);for(var n in j){if(!isNaN(n)){m.push(a(j[n]))}}}var p=d(o,k);if(p.file!==undefined){m[0]={file:p.file}}p.levels=m;return p}function a(k,j){j=c("source",j);var i=d(k,j);i.width=i.width?i.width:0;i.bitrate=i.bitrate?i.bitrate:0;return i}function b(k,j){j=c("video",j);var i=h(k,j);return i}f.media=h;f.audio=h;f.source=a;f.video=b})(jwplayer);jwplayer.utils.selectors=function(a,c){if(c===undefined){c=document}a=jwplayer.utils.strings.trim(a);var b=a.charAt(0);if(b=="#"){return c.getElementById(a.substr(1))}else{if(b=="."){if(c.getElementsByClassName){return c.getElementsByClassName(a.substr(1))}else{return jwplayer.utils.selectors.getElementsByTagAndClass("*",a.substr(1))}}else{if(a.indexOf(".")>0){selectors=a.split(".");return jwplayer.utils.selectors.getElementsByTagAndClass(selectors[0],selectors[1])}else{return c.getElementsByTagName(a)}}}return null};jwplayer.utils.selectors.getElementsByTagAndClass=function(d,g,f){elements=[];if(f===undefined){f=document}var e=f.getElementsByTagName(d);for(var c=0;c<e.length;c++){if(e[c].className!==undefined){var b=e[c].className.split(" ");for(var a=0;a<b.length;a++){if(b[a]==g){elements.push(e[c])}}}}return elements};jwplayer.utils.strings=function(){};jwplayer.utils.strings.trim=function(a){return a.replace(/^\s*/,"").replace(/\s*$/,"")};(function(b){var a=[];b.constructor=function(c){return b.api.selectPlayer(c)};b.api=function(){};b.api.events={API_READY:"jwplayerAPIReady",JWPLAYER_READY:"jwplayerReady",JWPLAYER_FULLSCREEN:"jwplayerFullscreen",JWPLAYER_RESIZE:"jwplayerResize",JWPLAYER_ERROR:"jwplayerError",JWPLAYER_MEDIA_BUFFER:"jwplayerMediaBuffer",JWPLAYER_MEDIA_BUFFER_FULL:"jwplayerMediaBufferFull",JWPLAYER_MEDIA_ERROR:"jwplayerMediaError",JWPLAYER_MEDIA_LOADED:"jwplayerMediaLoaded",JWPLAYER_MEDIA_COMPLETE:"jwplayerMediaComplete",JWPLAYER_MEDIA_TIME:"jwplayerMediaTime",JWPLAYER_MEDIA_VOLUME:"jwplayerMediaVolume",JWPLAYER_MEDIA_META:"jwplayerMediaMeta",JWPLAYER_MEDIA_MUTE:"jwplayerMediaMute",JWPLAYER_PLAYER_STATE:"jwplayerPlayerState",JWPLAYER_PLAYLIST_LOADED:"jwplayerPlaylistLoaded",JWPLAYER_PLAYLIST_ITEM:"jwplayerPlaylistItem"};b.api.events.state={BUFFERING:"BUFFERING",IDLE:"IDLE",PAUSED:"PAUSED",PLAYING:"PLAYING"};b.api.PlayerAPI=function(d){this.container=d;this.id=d.id;var j={};var n={};var c=[];var g=undefined;var i=false;var h=[];var l=d.outerHTML;var m={};this.setPlayer=function(o){g=o};this.stateListener=function(o,p){if(!n[o]){n[o]=[];this.eventListener(b.api.events.JWPLAYER_PLAYER_STATE,f(o))}n[o].push(p);return this};function f(o){return function(q){var p=q.newstate,s=q.oldstate;if(p==o){var r=n[p];if(r){for(var t in r){if(typeof r[t]=="function"){r[t].call(this,{oldstate:s,newstate:p})}}}}}}this.addInternalListener=function(o,p){o.jwAddEventListener(p,'function(dat) { jwplayer("'+this.id+'").dispatchEvent("'+p+'", dat); }')};this.eventListener=function(o,p){if(!j[o]){j[o]=[];if(g&&i){this.addInternalListener(g,o)}}j[o].push(p);return this};this.dispatchEvent=function(q){if(j[q]){var p=e(q,arguments[1]);for(var o in j[q]){if(typeof j[q][o]=="function"){j[q][o].call(this,p)}}}};function e(p,o){var q=b.utils.extend({},o);if(p==b.api.events.JWPLAYER_FULLSCREEN){q.fullscreen=q.message;delete q.message}else{if(typeof q.data=="object"){q=b.utils.extend(q,q.data);delete q.data}}return q}this.callInternal=function(p,o){if(i){if(typeof g!="undefined"&&typeof g[p]=="function"){if(o!==undefined){return(g[p])(o)}else{return(g[p])()}}return null}else{h.push({method:p,parameters:o})}};this.playerReady=function(q){i=true;if(!g){this.setPlayer(document.getElementById(q.id))}for(var o in j){this.addInternalListener(g,o)}this.eventListener(b.api.events.JWPLAYER_PLAYLIST_ITEM,function(r){m={}});this.eventListener(b.api.events.JWPLAYER_MEDIA_META,function(r){b.utils.extend(m,r.metadata)});this.dispatchEvent(b.api.events.API_READY);while(h.length>0){var p=h.shift();this.callInternal(p.method,p.parameters)}};this.getItemMeta=function(){return m};this.destroy=function(){j={};h=[];if(this.container.outerHTML!=l){b.api.destroyPlayer(this.id,l)}};function k(q,s,r){var o=[];if(!s){s=0}if(!r){r=q.length-1}for(var p=s;p<=r;p++){o.push(q[p])}return o}};b.api.PlayerAPI.prototype={container:undefined,options:undefined,id:undefined,getBuffer:function(){return this.callInternal("jwGetBuffer")},getDuration:function(){return this.callInternal("jwGetDuration")},getFullscreen:function(){return this.callInternal("jwGetFullscreen")},getHeight:function(){return this.callInternal("jwGetHeight")},getLockState:function(){return this.callInternal("jwGetLockState")},getMeta:function(){return this.getItemMeta()},getMute:function(){return this.callInternal("jwGetMute")},getPlaylist:function(){return this.callInternal("jwGetPlaylist")},getPlaylistItem:function(c){if(c==undefined){c=0}return this.getPlaylist()[c]},getPosition:function(){return this.callInternal("jwGetPosition")},getState:function(){return this.callInternal("jwGetState")},getVolume:function(){return this.callInternal("jwGetVolume")},getWidth:function(){return this.callInternal("jwGetWidth")},setFullscreen:function(c){this.callInternal("jwSetFullscreen",c);return this},setMute:function(c){this.callInternal("jwSetMute",c);return this},lock:function(){return this},unlock:function(){return this},load:function(c){this.callInternal("jwLoad",c);return this},playlistItem:function(c){this.callInternal("jwPlaylistItem",c);return this},playlistPrev:function(){this.callInternal("jwPlaylistPrev");return this},playlistNext:function(){this.callInternal("jwPlaylistNext");return this},resize:function(d,c){this.container.width=d;this.container.height=c;return this},play:function(c){if(typeof c==="undefined"){var c=this.getState();if(c==b.api.events.state.PLAYING||c==b.api.events.state.BUFFERING){this.callInternal("jwPause")}else{this.callInternal("jwPlay")}}else{this.callInternal("jwPlay",c)}return this},pause:function(){var c=this.getState();switch(c){case b.api.events.state.PLAYING:case b.api.events.state.BUFFERING:this.callInternal("jwPause");break;case b.api.events.state.PAUSED:this.callInternal("jwPlay");break}return this},stop:function(){this.callInternal("jwStop");return this},seek:function(c){this.callInternal("jwSeek",c);return this},setVolume:function(c){this.callInternal("jwSetVolume",c);return this},onBufferChange:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_BUFFER,c)},onBufferFull:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_BUFFER_FULL,c)},onError:function(c){return this.eventListener(b.api.events.JWPLAYER_ERROR,c)},onFullscreen:function(c){return this.eventListener(b.api.events.JWPLAYER_FULLSCREEN,c)},onMeta:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_META,c)},onMute:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_MUTE,c)},onPlaylist:function(c){return this.eventListener(b.api.events.JWPLAYER_PLAYLIST_LOADED,c)},onPlaylistItem:function(c){return this.eventListener(b.api.events.JWPLAYER_PLAYLIST_ITEM,c)},onReady:function(c){return this.eventListener(b.api.events.API_READY,c)},onResize:function(c){return this.eventListener(b.api.events.JWPLAYER_RESIZE,c)},onComplete:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_COMPLETE,c)},onTime:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_TIME,c)},onVolume:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_VOLUME,c)},onBuffer:function(c){return this.stateListener(b.api.events.state.BUFFERING,c)},onPause:function(c){return this.stateListener(b.api.events.state.PAUSED,c)},onPlay:function(c){return this.stateListener(b.api.events.state.PLAYING,c)},onIdle:function(c){return this.stateListener(b.api.events.state.IDLE,c)},setup:function(c){return this},remove:function(){this.destroy()},initializePlugin:function(c,d){return this}};b.api.selectPlayer=function(d){var c;if(d==undefined){d=0}if(d.nodeType){c=d}else{if(typeof d=="string"){c=document.getElementById(d)}}if(c){var e=b.api.playerById(c.id);if(e){return e}else{return b.api.addPlayer(new b.api.PlayerAPI(c))}}else{if(typeof d=="number"){return b.getPlayers()[d]}}return null};b.api.playerById=function(d){for(var c in a){if(a[c].id==d){return a[c]}}return null};b.api.addPlayer=function(d){for(var c in a){if(a[c]==d){return d}}a.push(d);return d};b.api.destroyPlayer=function(f,d){var e=-1;for(var h in a){if(a[h].id==f){e=h;continue}}if(e>=0){var c=document.getElementById(a[e].id);if(c){if(d){c.outerHTML=d}else{var g=document.createElement("div");g.setAttribute("id",c.id);c.parentNode.replaceChild(g,c)}}a.splice(e,1)}return null};b.getPlayers=function(){return a.slice(0)}})(jwplayer);var _userPlayerReady=(typeof playerReady=="function")?playerReady:undefined;playerReady=function(b){var a=jwplayer.api.playerById(b.id);if(a){a.playerReady(b)}if(_userPlayerReady){_userPlayerReady.call(this,b)}};(function(a){a.embed=function(){};a.embed.Embedder=function(b){this.constructor(b)};a.embed.defaults={width:400,height:300,players:[{type:"flash",src:"player.swf"},{type:"html5"}],components:{controlbar:{position:"over"}}};a.embed.Embedder.prototype={config:undefined,api:undefined,events:{},players:undefined,constructor:function(c){this.api=c;var b=a.utils.mediaparser.parseMedia(this.api.container);this.config=this.parseConfig(a.utils.extend({},a.embed.defaults,b,this.api.config))},embedPlayer:function(){var b=this.players[0];if(b&&b.type){switch(b.type){case"flash":if(a.utils.hasFlash()){if(this.config.levels||this.config.playlist){this.api.onReady(this.loadAfterReady(this.config))}this.config.id=this.api.id;var d=a.embed.embedFlash(document.getElementById(this.api.id),b,this.config);this.api.container=d;this.api.setPlayer(d)}else{this.players.splice(0,1);this.embedPlayer()}break;case"html5":if(a.utils.hasHTML5()){var c=a.embed.embedHTML5(document.getElementById(this.api.id),b,this.config);this.api.container=document.getElementById(this.api.id);this.api.setPlayer(c)}else{this.players.splice(0,1);this.embedPlayer()}break}}else{this.api.container.innerHTML="<p>No suitable players found</p>"}this.setupEvents();return this.api},setupEvents:function(){for(event in this.events){if(typeof this.api[event]=="function"){(this.api[event]).call(this.api,this.events[event])}}},loadAfterReady:function(b){return function(d){if(b.playlist){this.load(b.playlist)}else{if(b.levels){var c=this.getPlaylistItem(0);console.log("Item: %o",c);if(!c){c={file:b.levels[0].file}}if(!c.image){c.image=this.config.image}c.levels=b.levels;this.load(c)}}}},parseConfig:function(b){var c=a.utils.extend({},b);if(c.events){this.events=c.events;delete c.events}if(c.players){this.players=c.players;delete c.players}if(c.plugins){if(typeof c.plugins=="object"){c=a.utils.extend(c,a.embed.parsePlugins(c.plugins))}}return c}};a.embed.embedFlash=function(d,h,c){var i=a.utils.extend({},c);var f=i.width;delete i.width;var b=i.height;delete i.height;if(i.levels&&i.levels.length&&i.file===undefined){}delete i.levels;delete i.playlist;a.embed.parseConfigBlock(i,"components");a.embed.parseConfigBlock(i,"providers");if(a.utils.isIE()){var e='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+f+'" height="'+b+'" id="'+d.id+'" name="'+d.id+'">';e+='<param name="movie" value="'+h.src+'">';e+='<param name="allowfullscreen" value="true">';e+='<param name="allowscriptaccess" value="always">';e+='<param name="flashvars" value="'+a.embed.jsonToFlashvars(i)+'">';e+="</object>";d.outerHTML=e;return document.getElementById(d.id)}else{var g=document.createElement("object");g.setAttribute("type","application/x-shockwave-flash");g.setAttribute("data",h.src);g.setAttribute("width",f);g.setAttribute("height",b);g.setAttribute("id",d.id);g.setAttribute("name",d.id);a.embed.appendAttribute(g,"allowfullscreen","true");a.embed.appendAttribute(g,"allowscriptaccess","always");a.embed.appendAttribute(g,"flashvars",a.embed.jsonToFlashvars(i));d.parentNode.replaceChild(g,d);return g}};a.embed.embedHTML5=function(c,e,d){if(a.html5){c.innerHTML="<p>Embedded HTML5 player goes here</p>";var b=a.utils.extend({screencolor:"0x000000"},d);a.embed.parseConfigBlock(b,"components");if(b.levels&&!b.sources){b.sources=d.levels}return new (a.html5(c)).setup(b)}else{return null}};a.embed.appendAttribute=function(c,b,d){var e=document.createElement("param");e.setAttribute("name",b);e.setAttribute("value",d);c.appendChild(e)};a.embed.jsonToFlashvars=function(c){var b="";for(key in c){b+=key+"="+escape(c[key])+"&"}return b.substring(0,b.length-1)};a.embed.parsePlugins=function(d){if(!d){return{}}var f={},e=[];for(plugin in d){var c=plugin.indexOf("-")>0?plugin.substring(0,plugin.indexOf("-")):plugin;var b=d[plugin];e.push(plugin);for(param in b){f[c+"."+param]=b[param]}}f.plugins=e.join(",");return f};a.embed.parseConfigBlock=function(e,d){if(e[d]){var g=e[d];for(var c in g){var b=g[c];if(typeof b=="string"){e[c]=b}else{for(var f in b){e[c+"."+f]=b[f]}}}delete e[d]}};a.api.PlayerAPI.prototype.setup=function(c,d){if(c&&c.flashplayer&&!c.players){c.players=[{type:"flash",src:c.flashplayer},{type:"html5"}];delete c.flashplayer}if(d&&!c.players){if(typeof d=="string"){c.players=[{type:"flash",src:d}]}else{if(d instanceof Array){c.players=d}else{if(typeof d=="object"&&d.type){c.players=[d]}}}}var b=this.id;this.remove();var e=a(b);e.config=c;return(new a.embed.Embedder(e)).embedPlayer()}})(jwplayer); 
     1jwplayer=function(a){return jwplayer.constructor(a)};jwplayer.constructor=function(a){};$jw=jwplayer;jwplayer.utils=function(){};jwplayer.utils.typeOf=function(b){var a=typeof b;if(a==="object"){if(b){if(b instanceof Array){a="array"}}else{a="null"}}return a};jwplayer.utils.extend=function(){var a=jwplayer.utils.extend["arguments"];if(a.length>1){for(var b=1;b<a.length;b++){for(element in a[b]){a[0][element]=a[b][element]}}return a[0]}return null};jwplayer.utils.html=function(a,b){a.innerHTML=b};jwplayer.utils.append=function(a,b){a.appendChild(b)};jwplayer.utils.wrap=function(a,b){a.parentNode.replaceChild(b,a);b.appendChild(a)};jwplayer.utils.ajax=function(d,c,a){var b;if(window.XMLHttpRequest){b=new XMLHttpRequest()}else{b=new ActiveXObject("Microsoft.XMLHTTP")}b.onreadystatechange=function(){if(b.readyState===4&&b.status===200){if(c){c(b)}}else{if(a){a(d)}}};b.open("GET",d,true);b.send();return b};jwplayer.utils.load=function(b,c,a){b.onreadystatechange=function(){if(b.readyState===4){if(b.status===200){if(c){c()}}else{if(a){a()}}}}};jwplayer.utils.find=function(b,a){return b.getElementsByTagName(a)};jwplayer.utils.append=function(a,b){a.appendChild(b)};jwplayer.utils.isIE=function(){return(!+"\v1")};jwplayer.utils.hasHTML5=function(){return !!document.createElement("video").canPlayType};jwplayer.utils.hasFlash=function(){return(typeof navigator.plugins!="undefined"&&typeof navigator.plugins["Shockwave Flash"]!="undefined")||(typeof window.ActiveXObject!="undefined")};(function(e){e.utils.mediaparser=function(){};var g={element:{width:"width",height:"height",id:"id","class":"className",name:"name"},media:{src:"file",preload:"preload",autoplay:"autostart",loop:"repeat",controls:"controls"},source:{src:"file",type:"type",media:"media","data-jw-width":"width","data-jw-bitrate":"bitrate"},video:{poster:"image"}};var f={};e.utils.mediaparser.parseMedia=function(i){return d(i)};function c(j,i){if(i===undefined){i=g[j]}else{e.utils.extend(i,g[j])}return i}function d(m,i){if(f[m.tagName.toLowerCase()]&&(i===undefined)){return f[m.tagName.toLowerCase()](m)}else{i=c("element",i);var n={};for(var j in i){if(j!="length"){var l=m.getAttribute(j);if(!(l===""||l===undefined||l===null)){n[i[j]]=m.getAttribute(j)}}}var k=m.style["#background-color"];if(k&&!(k=="transparent"||k=="rgba(0, 0, 0, 0)")){n.screencolor=k}return n}}function h(o,k){k=c("media",k);var m=[];if(!(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length)){var l=o.nextSibling;if(l!==undefined){while(l.tagName.toLowerCase()=="source"){m.push(a(l));l=l.nextSibling}}}else{var j=e.utils.selectors("source",o);for(var n in j){if(!isNaN(n)){m.push(a(j[n]))}}}var p=d(o,k);if(p.file!==undefined){m[0]={file:p.file}}p.levels=m;return p}function a(k,j){j=c("source",j);var i=d(k,j);i.width=i.width?i.width:0;i.bitrate=i.bitrate?i.bitrate:0;return i}function b(k,j){j=c("video",j);var i=h(k,j);return i}f.media=h;f.audio=h;f.source=a;f.video=b})(jwplayer);jwplayer.utils.selectors=function(a,c){if(c===undefined){c=document}a=jwplayer.utils.strings.trim(a);var b=a.charAt(0);if(b=="#"){return c.getElementById(a.substr(1))}else{if(b=="."){if(c.getElementsByClassName){return c.getElementsByClassName(a.substr(1))}else{return jwplayer.utils.selectors.getElementsByTagAndClass("*",a.substr(1))}}else{if(a.indexOf(".")>0){selectors=a.split(".");return jwplayer.utils.selectors.getElementsByTagAndClass(selectors[0],selectors[1])}else{return c.getElementsByTagName(a)}}}return null};jwplayer.utils.selectors.getElementsByTagAndClass=function(d,g,f){elements=[];if(f===undefined){f=document}var e=f.getElementsByTagName(d);for(var c=0;c<e.length;c++){if(e[c].className!==undefined){var b=e[c].className.split(" ");for(var a=0;a<b.length;a++){if(b[a]==g){elements.push(e[c])}}}}return elements};jwplayer.utils.strings=function(){};jwplayer.utils.strings.trim=function(a){return a.replace(/^\s*/,"").replace(/\s*$/,"")};(function(b){var a=[];b.constructor=function(c){return b.api.selectPlayer(c)};b.api=function(){};b.api.events={API_READY:"jwplayerAPIReady",JWPLAYER_READY:"jwplayerReady",JWPLAYER_FULLSCREEN:"jwplayerFullscreen",JWPLAYER_RESIZE:"jwplayerResize",JWPLAYER_ERROR:"jwplayerError",JWPLAYER_MEDIA_BUFFER:"jwplayerMediaBuffer",JWPLAYER_MEDIA_BUFFER_FULL:"jwplayerMediaBufferFull",JWPLAYER_MEDIA_ERROR:"jwplayerMediaError",JWPLAYER_MEDIA_LOADED:"jwplayerMediaLoaded",JWPLAYER_MEDIA_COMPLETE:"jwplayerMediaComplete",JWPLAYER_MEDIA_TIME:"jwplayerMediaTime",JWPLAYER_MEDIA_VOLUME:"jwplayerMediaVolume",JWPLAYER_MEDIA_META:"jwplayerMediaMeta",JWPLAYER_MEDIA_MUTE:"jwplayerMediaMute",JWPLAYER_PLAYER_STATE:"jwplayerPlayerState",JWPLAYER_PLAYLIST_LOADED:"jwplayerPlaylistLoaded",JWPLAYER_PLAYLIST_ITEM:"jwplayerPlaylistItem"};b.api.events.state={BUFFERING:"BUFFERING",IDLE:"IDLE",PAUSED:"PAUSED",PLAYING:"PLAYING"};b.api.PlayerAPI=function(d){this.container=d;this.id=d.id;var j={};var n={};var c=[];var g=undefined;var i=false;var h=[];var l=d.outerHTML;var m={};this.setPlayer=function(o){g=o};this.stateListener=function(o,p){if(!n[o]){n[o]=[];this.eventListener(b.api.events.JWPLAYER_PLAYER_STATE,f(o))}n[o].push(p);return this};function f(o){return function(q){var p=q.newstate,s=q.oldstate;if(p==o){var r=n[p];if(r){for(var t in r){if(typeof r[t]=="function"){r[t].call(this,{oldstate:s,newstate:p})}}}}}}this.addInternalListener=function(o,p){o.jwAddEventListener(p,'function(dat) { jwplayer("'+this.id+'").dispatchEvent("'+p+'", dat); }')};this.eventListener=function(o,p){if(!j[o]){j[o]=[];if(g&&i){this.addInternalListener(g,o)}}j[o].push(p);return this};this.dispatchEvent=function(q){if(j[q]){var p=e(q,arguments[1]);for(var o in j[q]){if(typeof j[q][o]=="function"){j[q][o].call(this,p)}}}};function e(p,o){var q=b.utils.extend({},o);if(p==b.api.events.JWPLAYER_FULLSCREEN){q.fullscreen=q.message;delete q.message}else{if(typeof q.data=="object"){q=b.utils.extend(q,q.data);delete q.data}}return q}this.callInternal=function(p,o){if(i){if(typeof g!="undefined"&&typeof g[p]=="function"){if(o!==undefined){return(g[p])(o)}else{return(g[p])()}}return null}else{h.push({method:p,parameters:o})}};this.playerReady=function(q){i=true;if(!g){this.setPlayer(document.getElementById(q.id))}for(var o in j){this.addInternalListener(g,o)}this.eventListener(b.api.events.JWPLAYER_PLAYLIST_ITEM,function(r){m={}});this.eventListener(b.api.events.JWPLAYER_MEDIA_META,function(r){b.utils.extend(m,r.metadata)});this.dispatchEvent(b.api.events.API_READY);while(h.length>0){var p=h.shift();this.callInternal(p.method,p.parameters)}};this.getItemMeta=function(){return m};this.destroy=function(){j={};h=[];if(this.container.outerHTML!=l){b.api.destroyPlayer(this.id,l)}};function k(q,s,r){var o=[];if(!s){s=0}if(!r){r=q.length-1}for(var p=s;p<=r;p++){o.push(q[p])}return o}};b.api.PlayerAPI.prototype={container:undefined,options:undefined,id:undefined,getBuffer:function(){return this.callInternal("jwGetBuffer")},getDuration:function(){return this.callInternal("jwGetDuration")},getFullscreen:function(){return this.callInternal("jwGetFullscreen")},getHeight:function(){return this.callInternal("jwGetHeight")},getLockState:function(){return this.callInternal("jwGetLockState")},getMeta:function(){return this.getItemMeta()},getMute:function(){return this.callInternal("jwGetMute")},getPlaylist:function(){return this.callInternal("jwGetPlaylist")},getPlaylistItem:function(c){if(c==undefined){c=0}return this.getPlaylist()[c]},getPosition:function(){return this.callInternal("jwGetPosition")},getState:function(){return this.callInternal("jwGetState")},getVolume:function(){return this.callInternal("jwGetVolume")},getWidth:function(){return this.callInternal("jwGetWidth")},setFullscreen:function(c){this.callInternal("jwSetFullscreen",c);return this},setMute:function(c){this.callInternal("jwSetMute",c);return this},lock:function(){return this},unlock:function(){return this},load:function(c){this.callInternal("jwLoad",c);return this},playlistItem:function(c){this.callInternal("jwPlaylistItem",c);return this},playlistPrev:function(){this.callInternal("jwPlaylistPrev");return this},playlistNext:function(){this.callInternal("jwPlaylistNext");return this},resize:function(d,c){this.container.width=d;this.container.height=c;return this},play:function(c){if(typeof c==="undefined"){var c=this.getState();if(c==b.api.events.state.PLAYING||c==b.api.events.state.BUFFERING){this.callInternal("jwPause")}else{this.callInternal("jwPlay")}}else{this.callInternal("jwPlay",c)}return this},pause:function(){var c=this.getState();switch(c){case b.api.events.state.PLAYING:case b.api.events.state.BUFFERING:this.callInternal("jwPause");break;case b.api.events.state.PAUSED:this.callInternal("jwPlay");break}return this},stop:function(){this.callInternal("jwStop");return this},seek:function(c){this.callInternal("jwSeek",c);return this},setVolume:function(c){this.callInternal("jwSetVolume",c);return this},onBufferChange:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_BUFFER,c)},onBufferFull:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_BUFFER_FULL,c)},onError:function(c){return this.eventListener(b.api.events.JWPLAYER_ERROR,c)},onFullscreen:function(c){return this.eventListener(b.api.events.JWPLAYER_FULLSCREEN,c)},onMeta:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_META,c)},onMute:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_MUTE,c)},onPlaylist:function(c){return this.eventListener(b.api.events.JWPLAYER_PLAYLIST_LOADED,c)},onPlaylistItem:function(c){return this.eventListener(b.api.events.JWPLAYER_PLAYLIST_ITEM,c)},onReady:function(c){return this.eventListener(b.api.events.API_READY,c)},onResize:function(c){return this.eventListener(b.api.events.JWPLAYER_RESIZE,c)},onComplete:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_COMPLETE,c)},onTime:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_TIME,c)},onVolume:function(c){return this.eventListener(b.api.events.JWPLAYER_MEDIA_VOLUME,c)},onBuffer:function(c){return this.stateListener(b.api.events.state.BUFFERING,c)},onPause:function(c){return this.stateListener(b.api.events.state.PAUSED,c)},onPlay:function(c){return this.stateListener(b.api.events.state.PLAYING,c)},onIdle:function(c){return this.stateListener(b.api.events.state.IDLE,c)},setup:function(c){return this},remove:function(){this.destroy()},initializePlugin:function(c,d){return this}};b.api.selectPlayer=function(d){var c;if(d==undefined){d=0}if(d.nodeType){c=d}else{if(typeof d=="string"){c=document.getElementById(d)}}if(c){var e=b.api.playerById(c.id);if(e){return e}else{return b.api.addPlayer(new b.api.PlayerAPI(c))}}else{if(typeof d=="number"){return b.getPlayers()[d]}}return null};b.api.playerById=function(d){for(var c in a){if(a[c].id==d){return a[c]}}return null};b.api.addPlayer=function(d){for(var c in a){if(a[c]==d){return d}}a.push(d);return d};b.api.destroyPlayer=function(f,d){var e=-1;for(var h in a){if(a[h].id==f){e=h;continue}}if(e>=0){var c=document.getElementById(a[e].id);if(c){if(d){c.outerHTML=d}else{var g=document.createElement("div");g.setAttribute("id",c.id);c.parentNode.replaceChild(g,c)}}a.splice(e,1)}return null};b.getPlayers=function(){return a.slice(0)}})(jwplayer);var _userPlayerReady=(typeof playerReady=="function")?playerReady:undefined;playerReady=function(b){var a=jwplayer.api.playerById(b.id);if(a){a.playerReady(b)}if(_userPlayerReady){_userPlayerReady.call(this,b)}};(function(a){a.embed=function(){};a.embed.Embedder=function(b){this.constructor(b)};a.embed.defaults={width:400,height:300,players:[{type:"flash",src:"player.swf"},{type:"html5"}],components:{controlbar:{position:"over"}}};a.embed.Embedder.prototype={config:undefined,api:undefined,events:{},players:undefined,constructor:function(c){this.api=c;var b=a.utils.mediaparser.parseMedia(this.api.container);this.config=this.parseConfig(a.utils.extend({},a.embed.defaults,b,this.api.config))},embedPlayer:function(){var b=this.players[0];if(b&&b.type){switch(b.type){case"flash":if(a.utils.hasFlash()){if(this.config.levels||this.config.playlist){this.api.onReady(this.loadAfterReady(this.config))}this.config.id=this.api.id;var d=a.embed.embedFlash(document.getElementById(this.api.id),b,this.config);this.api.container=d;this.api.setPlayer(d)}else{this.players.splice(0,1);return this.embedPlayer()}break;case"html5":if(a.utils.hasHTML5()){var c=a.embed.embedHTML5(document.getElementById(this.api.id),b,this.config);this.api.container=document.getElementById(this.api.id);this.api.setPlayer(c)}else{this.players.splice(0,1);return this.embedPlayer()}break}}else{this.api.container.innerHTML="<p>No suitable players found</p>"}this.setupEvents();return this.api},setupEvents:function(){for(evt in this.events){if(typeof this.api[evt]=="function"){(this.api[evt]).call(this.api,this.events[evt])}}},loadAfterReady:function(b){return function(d){if(b.playlist){this.load(b.playlist)}else{if(b.levels){var c=this.getPlaylistItem(0);if(!c){c={file:b.levels[0].file,provider:"video"}}if(!c.image){c.image=this.config.image}c.levels=b.levels;this.load(c)}}}},parseConfig:function(b){var c=a.utils.extend({},b);if(c.events){this.events=c.events;delete c.events}if(c.players){this.players=c.players;delete c.players}if(c.plugins){if(typeof c.plugins=="object"){c=a.utils.extend(c,a.embed.parsePlugins(c.plugins))}}return c}};a.embed.embedFlash=function(d,h,c){var i=a.utils.extend({},c);var f=i.width;delete i.width;var b=i.height;delete i.height;if(i.levels&&i.levels.length&&i.file===undefined){}delete i.levels;delete i.playlist;a.embed.parseConfigBlock(i,"components");a.embed.parseConfigBlock(i,"providers");if(a.utils.isIE()){var e='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+f+'" height="'+b+'" id="'+d.id+'" name="'+d.id+'">';e+='<param name="movie" value="'+h.src+'">';e+='<param name="allowfullscreen" value="true">';e+='<param name="allowscriptaccess" value="always">';e+='<param name="flashvars" value="'+a.embed.jsonToFlashvars(i)+'">';e+="</object>";d.outerHTML=e;return document.getElementById(d.id)}else{var g=document.createElement("object");g.setAttribute("type","application/x-shockwave-flash");g.setAttribute("data",h.src);g.setAttribute("width",f);g.setAttribute("height",b);g.setAttribute("id",d.id);g.setAttribute("name",d.id);a.embed.appendAttribute(g,"allowfullscreen","true");a.embed.appendAttribute(g,"allowscriptaccess","always");a.embed.appendAttribute(g,"flashvars",a.embed.jsonToFlashvars(i));d.parentNode.replaceChild(g,d);return g}};a.embed.embedHTML5=function(c,e,d){if(a.html5){c.innerHTML="<p>Embedded HTML5 player goes here</p>";var b=a.utils.extend({screencolor:"0x000000"},d);a.embed.parseConfigBlock(b,"components");if(b.levels&&!b.sources){b.sources=d.levels}return new (a.html5(c)).setup(b)}else{return null}};a.embed.appendAttribute=function(c,b,d){var e=document.createElement("param");e.setAttribute("name",b);e.setAttribute("value",d);c.appendChild(e)};a.embed.jsonToFlashvars=function(c){var b="";for(key in c){b+=key+"="+escape(c[key])+"&"}return b.substring(0,b.length-1)};a.embed.parsePlugins=function(d){if(!d){return{}}var f={},e=[];for(plugin in d){var c=plugin.indexOf("-")>0?plugin.substring(0,plugin.indexOf("-")):plugin;var b=d[plugin];e.push(plugin);for(param in b){f[c+"."+param]=b[param]}}f.plugins=e.join(",");return f};a.embed.parseConfigBlock=function(e,d){if(e[d]){var g=e[d];for(var c in g){var b=g[c];if(typeof b=="string"){e[c]=b}else{for(var f in b){e[c+"."+f]=b[f]}}}delete e[d]}};a.api.PlayerAPI.prototype.setup=function(c,d){if(c&&c.flashplayer&&!c.players){c.players=[{type:"flash",src:c.flashplayer},{type:"html5"}];delete c.flashplayer}if(d&&!c.players){if(typeof d=="string"){c.players=[{type:"flash",src:d}]}else{if(d instanceof Array){c.players=d}else{if(typeof d=="object"&&d.type){c.players=[d]}}}}var b=this.id;this.remove();var e=a(b);e.config=c;return(new a.embed.Embedder(e)).embedPlayer()}})(jwplayer); 
  • trunk/js/src/embed/jwplayer.embed.js

    r1276 r1308  
    5353                                        } else { 
    5454                                                this.players.splice(0, 1); 
    55                                                 this.embedPlayer(); 
     55                                                return this.embedPlayer(); 
     56                                                 
    5657                                        } 
    5758                                        break; 
     
    6364                                        } else { 
    6465                                                this.players.splice(0, 1); 
    65                                                 this.embedPlayer(); 
     66                                                return this.embedPlayer(); 
    6667                                        } 
    6768                                        break; 
     
    7778 
    7879                setupEvents : function() { 
    79                         for (event in this.events) { 
    80                                 if (typeof this.api[event] == "function") { 
    81                                         (this.api[event]).call(this.api, this.events[event]); 
     80                        for (evt in this.events) { 
     81                                if (typeof this.api[evt] == "function") { 
     82                                        (this.api[evt]).call(this.api, this.events[evt]); 
    8283                                } 
    8384                        } 
     
    9091                                } else if (loadParams.levels) { 
    9192                                        var item = this.getPlaylistItem(0); 
    92                                         console.log("Item: %o", item); 
    9393                                        if (!item) { 
    94                                                 item = { file: loadParams.levels[0].file }; 
     94                                                item = { file: loadParams.levels[0].file, provider:'video' }; 
    9595                                        } 
    9696                                        if (!item.image) { 
  • trunk/js/src/utils/jwplayer.utils.mediaparser.js

    r1276 r1308  
    8282                        // IE6/7/8 case 
    8383                        var currentElement = domElement.nextSibling; 
    84                         if (currentElement[0] !== undefined){ 
    85                                 while(currentElement[0].tagName.toLowerCase() == "source") { 
    86                                         sources.push(parseSourceElement(currentElement[0])); 
     84                        if (currentElement !== undefined){ 
     85                                while(currentElement.tagName.toLowerCase() == "source") { 
     86                                        sources.push(parseSourceElement(currentElement)); 
    8787                                        currentElement = currentElement.nextSibling; 
    8888                                }                                
  • trunk/js/test/embed.html

    r1262 r1308  
    1010                                        {file: '../../../testing/files/bunny.mp4'} 
    1111                                ] 
    12                         };  
     12                        }; 
     13                          
    1314                        function embedPlayer(id) { 
    14                                 $jw(id).setup(options, '../../../trunk/fl5/player.swf').onPlay(function() { 
     15                                $jw(id).setup(options,'/trunk/fl5/player.swf').onPlay(function() { 
    1516                                        alert("Playing!"); 
    1617                                }).play(); 
     
    2425                        <div id="div1"></div> 
    2526                </div> 
    26                 <div id="something_else"> 
    27                         <div id="div2"> 
    28                                 This is &lt;div&gt; 2 
    29                         </div> 
    30                 </div> 
    3127                <h3>Embed a player on a div</h3> 
    3228                <a href="#" onclick="embedPlayer('div1'); return false;">Click here to embed player</a><br /> 
     
    3531                        <video id="a_video" src="/testing/files/bunny.mp4" width="320" height="240" poster="/testing/files/bunny.png"></video> 
    3632                </div> 
    37                 <a href="#" onclick="console.log($jw('a_video').setup().options); return false;">Click here to embed player</a><br /> 
     33                <a href="#" onclick="console.log($jw('a_video').setup({flashplayer:'/trunk/fl5/player.swf'}).play().options); return false;">Click here to embed player</a><br /> 
    3834        </body> 
    3935</html> 
Note: See TracChangeset for help on using the changeset viewer.