增加jplayer插件
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Playlist Object for the jPlayer Plugin
|
||||
* http://www.jplayer.org
|
||||
*
|
||||
* Copyright (c) 2009 - 2011 Happyworm Ltd
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* - http://www.opensource.org/licenses/mit-license.php
|
||||
* - http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* Author: Mark J Panaghiston
|
||||
* Version: 2.1.0 (jPlayer 2.1.0)
|
||||
* Date: 1st September 2011
|
||||
*/
|
||||
|
||||
(function(b,f){jPlayerPlaylist=function(a,c,d){var e=this;this.current=0;this.removing=this.shuffled=this.loop=!1;this.cssSelector=b.extend({},this._cssSelector,a);this.options=b.extend(!0,{},this._options,d);this.playlist=[];this.original=[];this._initPlaylist(c);this.cssSelector.title=this.cssSelector.cssSelectorAncestor+" .jp-title";this.cssSelector.playlist=this.cssSelector.cssSelectorAncestor+" .jp-playlist";this.cssSelector.next=this.cssSelector.cssSelectorAncestor+" .jp-next";this.cssSelector.previous=
|
||||
this.cssSelector.cssSelectorAncestor+" .jp-previous";this.cssSelector.shuffle=this.cssSelector.cssSelectorAncestor+" .jp-shuffle";this.cssSelector.shuffleOff=this.cssSelector.cssSelectorAncestor+" .jp-shuffle-off";this.options.cssSelectorAncestor=this.cssSelector.cssSelectorAncestor;this.options.repeat=function(a){e.loop=a.jPlayer.options.loop};b(this.cssSelector.jPlayer).bind(b.jPlayer.event.ready,function(){e._init()});b(this.cssSelector.jPlayer).bind(b.jPlayer.event.ended,function(){e.next()});
|
||||
b(this.cssSelector.jPlayer).bind(b.jPlayer.event.play,function(){b(this).jPlayer("pauseOthers")});b(this.cssSelector.jPlayer).bind(b.jPlayer.event.resize,function(a){a.jPlayer.options.fullScreen?b(e.cssSelector.title).show():b(e.cssSelector.title).hide()});b(this.cssSelector.previous).click(function(){e.previous();b(this).blur();return!1});b(this.cssSelector.next).click(function(){e.next();b(this).blur();return!1});b(this.cssSelector.shuffle).click(function(){e.shuffle(!0);return!1});b(this.cssSelector.shuffleOff).click(function(){e.shuffle(!1);
|
||||
return!1}).hide();this.options.fullScreen||b(this.cssSelector.title).hide();b(this.cssSelector.playlist+" ul").empty();this._createItemHandlers();b(this.cssSelector.jPlayer).jPlayer(this.options)};jPlayerPlaylist.prototype={_cssSelector:{jPlayer:"#jquery_jplayer_1",cssSelectorAncestor:"#jp_container_1"},_options:{playlistOptions:{autoPlay:!1,loopOnPrevious:!1,shuffleOnLoop:!0,enableRemoveControls:!1,displayTime:"slow",addTime:"fast",removeTime:"fast",shuffleTime:"slow",itemClass:"jp-playlist-item",
|
||||
freeGroupClass:"jp-free-media",freeItemClass:"jp-playlist-item-free",removeItemClass:"jp-playlist-item-remove"}},option:function(a,b){if(b===f)return this.options.playlistOptions[a];this.options.playlistOptions[a]=b;switch(a){case "enableRemoveControls":this._updateControls();break;case "itemClass":case "freeGroupClass":case "freeItemClass":case "removeItemClass":this._refresh(!0),this._createItemHandlers()}return this},_init:function(){var a=this;this._refresh(function(){a.options.playlistOptions.autoPlay?
|
||||
a.play(a.current):a.select(a.current)})},_initPlaylist:function(a){this.current=0;this.removing=this.shuffled=!1;this.original=b.extend(!0,[],a);this._originalPlaylist()},_originalPlaylist:function(){var a=this;this.playlist=[];b.each(this.original,function(b){a.playlist[b]=a.original[b]})},_refresh:function(a){var c=this;if(a&&!b.isFunction(a))b(this.cssSelector.playlist+" ul").empty(),b.each(this.playlist,function(a){b(c.cssSelector.playlist+" ul").append(c._createListItem(c.playlist[a]))}),this._updateControls();
|
||||
else{var d=b(this.cssSelector.playlist+" ul").children().length?this.options.playlistOptions.displayTime:0;b(this.cssSelector.playlist+" ul").slideUp(d,function(){var d=b(this);b(this).empty();b.each(c.playlist,function(a){d.append(c._createListItem(c.playlist[a]))});c._updateControls();b.isFunction(a)&&a();c.playlist.length?b(this).slideDown(c.options.playlistOptions.displayTime):b(this).show()})}},_createListItem:function(a){var c=this,d="<li><div>";d+="<a href='javascript:;' class='"+this.options.playlistOptions.removeItemClass+
|
||||
"'>×</a>";if(a.free){var e=!0;d+="<span class='"+this.options.playlistOptions.freeGroupClass+"'>(";b.each(a,function(a,f){b.jPlayer.prototype.format[a]&&(e?e=!1:d+=" | ",d+="<a class='"+c.options.playlistOptions.freeItemClass+"' href='"+f+"' tabindex='1'>"+a+"</a>")});d+=")</span>"}d+="<a href='javascript:;' class='"+this.options.playlistOptions.itemClass+"' tabindex='1'>"+a.title+(a.artist?" <span class='jp-artist'>by "+a.artist+"</span>":"")+"</a>";d+="</div></li>";return d},_createItemHandlers:function(){var a=
|
||||
this;b(this.cssSelector.playlist+" a."+this.options.playlistOptions.itemClass).die("click").live("click",function(){var c=b(this).parent().parent().index();a.current!==c?a.play(c):b(a.cssSelector.jPlayer).jPlayer("play");b(this).blur();return!1});b(a.cssSelector.playlist+" a."+this.options.playlistOptions.freeItemClass).die("click").live("click",function(){b(this).parent().parent().find("."+a.options.playlistOptions.itemClass).click();b(this).blur();return!1});b(a.cssSelector.playlist+" a."+this.options.playlistOptions.removeItemClass).die("click").live("click",
|
||||
function(){var c=b(this).parent().parent().index();a.remove(c);b(this).blur();return!1})},_updateControls:function(){this.options.playlistOptions.enableRemoveControls?b(this.cssSelector.playlist+" ."+this.options.playlistOptions.removeItemClass).show():b(this.cssSelector.playlist+" ."+this.options.playlistOptions.removeItemClass).hide();this.shuffled?(b(this.cssSelector.shuffleOff).show(),b(this.cssSelector.shuffle).hide()):(b(this.cssSelector.shuffleOff).hide(),b(this.cssSelector.shuffle).show())},
|
||||
_highlight:function(a){this.playlist.length&&a!==f&&(b(this.cssSelector.playlist+" .jp-playlist-current").removeClass("jp-playlist-current"),b(this.cssSelector.playlist+" li:nth-child("+(a+1)+")").addClass("jp-playlist-current").find(".jp-playlist-item").addClass("jp-playlist-current"),b(this.cssSelector.title+" li").html(this.playlist[a].title+(this.playlist[a].artist?" <span class='jp-artist'>by "+this.playlist[a].artist+"</span>":"")))},setPlaylist:function(a){this._initPlaylist(a);this._init()},
|
||||
add:function(a,c){b(this.cssSelector.playlist+" ul").append(this._createListItem(a)).find("li:last-child").hide().slideDown(this.options.playlistOptions.addTime);this._updateControls();this.original.push(a);this.playlist.push(a);c?this.play(this.playlist.length-1):this.original.length===1&&this.select(0)},remove:function(a){var c=this;if(a===f)return this._initPlaylist([]),this._refresh(function(){b(c.cssSelector.jPlayer).jPlayer("clearMedia")}),!0;else if(this.removing)return!1;else{a=a<0?c.original.length+
|
||||
a:a;if(0<=a&&a<this.playlist.length)this.removing=!0,b(this.cssSelector.playlist+" li:nth-child("+(a+1)+")").slideUp(this.options.playlistOptions.removeTime,function(){b(this).remove();if(c.shuffled){var d=c.playlist[a];b.each(c.original,function(a){if(c.original[a]===d)return c.original.splice(a,1),!1})}else c.original.splice(a,1);c.playlist.splice(a,1);c.original.length?a===c.current?(c.current=a<c.original.length?c.current:c.original.length-1,c.select(c.current)):a<c.current&&c.current--:(b(c.cssSelector.jPlayer).jPlayer("clearMedia"),
|
||||
c.current=0,c.shuffled=!1,c._updateControls());c.removing=!1});return!0}},select:function(a){a=a<0?this.original.length+a:a;0<=a&&a<this.playlist.length?(this.current=a,this._highlight(a),b(this.cssSelector.jPlayer).jPlayer("setMedia",this.playlist[this.current])):this.current=0},play:function(a){a=a<0?this.original.length+a:a;0<=a&&a<this.playlist.length?this.playlist.length&&(this.select(a),b(this.cssSelector.jPlayer).jPlayer("play")):a===f&&b(this.cssSelector.jPlayer).jPlayer("play")},pause:function(){b(this.cssSelector.jPlayer).jPlayer("pause")},
|
||||
next:function(){var a=this.current+1<this.playlist.length?this.current+1:0;this.loop?a===0&&this.shuffled&&this.options.playlistOptions.shuffleOnLoop&&this.playlist.length>1?this.shuffle(!0,!0):this.play(a):a>0&&this.play(a)},previous:function(){var a=this.current-1>=0?this.current-1:this.playlist.length-1;(this.loop&&this.options.playlistOptions.loopOnPrevious||a<this.playlist.length-1)&&this.play(a)},shuffle:function(a,c){var d=this;a===f&&(a=!this.shuffled);(a||a!==this.shuffled)&&b(this.cssSelector.playlist+
|
||||
" ul").slideUp(this.options.playlistOptions.shuffleTime,function(){(d.shuffled=a)?d.playlist.sort(function(){return 0.5-Math.random()}):d._originalPlaylist();d._refresh(!0);c||!b(d.cssSelector.jPlayer).data("jPlayer").status.paused?d.play(0):d.select(0);b(this).slideDown(d.options.playlistOptions.shuffleTime)})}}})(jQuery);
|
|
@ -0,0 +1,331 @@
|
|||
/*
|
||||
* jPlayerInspector Plugin for jPlayer (2.0.0+) Plugin for jQuery JavaScript Library
|
||||
* http://www.happyworm.com/jquery/jplayer
|
||||
*
|
||||
* Copyright (c) 2009 - 2011 Happyworm Ltd
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* - http://www.opensource.org/licenses/mit-license.php
|
||||
* - http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* Author: Mark J Panaghiston
|
||||
* Version: 1.0.3
|
||||
* Date: 7th August 2011
|
||||
*
|
||||
* For use with jPlayer Version: 2.0.29
|
||||
*
|
||||
* Note: Declare inspector instances after jPlayer instances. ie., Otherwise the jPlayer instance is nonsense.
|
||||
*/
|
||||
|
||||
(function($, undefined) {
|
||||
$.jPlayerInspector = {};
|
||||
$.jPlayerInspector.i = 0;
|
||||
$.jPlayerInspector.defaults = {
|
||||
jPlayer: undefined, // The jQuery selector of the jPlayer instance to inspect.
|
||||
idPrefix: "jplayer_inspector_",
|
||||
visible: false
|
||||
};
|
||||
|
||||
var methods = {
|
||||
init: function(options) {
|
||||
var self = this;
|
||||
var $this = $(this);
|
||||
|
||||
var config = $.extend({}, $.jPlayerInspector.defaults, options);
|
||||
$(this).data("jPlayerInspector", config);
|
||||
|
||||
config.id = $(this).attr("id");
|
||||
config.jPlayerId = config.jPlayer.attr("id");
|
||||
|
||||
config.windowId = config.idPrefix + "window_" + $.jPlayerInspector.i;
|
||||
config.statusId = config.idPrefix + "status_" + $.jPlayerInspector.i;
|
||||
config.configId = config.idPrefix + "config_" + $.jPlayerInspector.i;
|
||||
config.toggleId = config.idPrefix + "toggle_" + $.jPlayerInspector.i;
|
||||
config.eventResetId = config.idPrefix + "event_reset_" + $.jPlayerInspector.i;
|
||||
config.updateId = config.idPrefix + "update_" + $.jPlayerInspector.i;
|
||||
config.eventWindowId = config.idPrefix + "event_window_" + $.jPlayerInspector.i;
|
||||
|
||||
config.eventId = {};
|
||||
config.eventJq = {};
|
||||
config.eventTimeout = {};
|
||||
config.eventOccurrence = {};
|
||||
|
||||
$.each($.jPlayer.event, function(eventName,eventType) {
|
||||
config.eventId[eventType] = config.idPrefix + "event_" + eventName + "_" + $.jPlayerInspector.i;
|
||||
config.eventOccurrence[eventType] = 0;
|
||||
});
|
||||
|
||||
var structure =
|
||||
'<p><a href="#" id="' + config.toggleId + '">' + (config.visible ? "Hide" : "Show") + '</a> jPlayer Inspector</p>'
|
||||
+ '<div id="' + config.windowId + '">'
|
||||
+ '<div id="' + config.statusId + '"></div>'
|
||||
+ '<div id="' + config.eventWindowId + '" style="padding:5px 5px 0 5px;background-color:#eee;border:1px dotted #000;">'
|
||||
+ '<p style="margin:0 0 10px 0;"><strong>jPlayer events that have occurred over the past 1 second:</strong>'
|
||||
+ '<br />(Backgrounds: <span style="padding:0 5px;background-color:#eee;border:1px dotted #000;">Never occurred</span> <span style="padding:0 5px;background-color:#fff;border:1px dotted #000;">Occurred before</span> <span style="padding:0 5px;background-color:#9f9;border:1px dotted #000;">Occurred</span> <span style="padding:0 5px;background-color:#ff9;border:1px dotted #000;">Multiple occurrences</span> <a href="#" id="' + config.eventResetId + '">reset</a>)</p>';
|
||||
|
||||
// MJP: Would use the next 3 lines for ease, but the events are just slapped on the page.
|
||||
// $.each($.jPlayer.event, function(eventName,eventType) {
|
||||
// structure += '<div id="' + config.eventId[eventType] + '" style="float:left;">' + eventName + '</div>';
|
||||
// });
|
||||
|
||||
var eventStyle = "float:left;margin:0 5px 5px 0;padding:0 5px;border:1px dotted #000;";
|
||||
// MJP: Doing it longhand so order and layout easier to control.
|
||||
structure +=
|
||||
'<div id="' + config.eventId[$.jPlayer.event.ready] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.flashreset] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.resize] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.repeat] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.click] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.error] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.warning] + '" style="' + eventStyle + '"></div>'
|
||||
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.loadstart] + '" style="clear:left;' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.progress] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.timeupdate] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.volumechange] + '" style="' + eventStyle + '"></div>'
|
||||
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.play] + '" style="clear:left;' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.pause] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.waiting] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.playing] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.seeking] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.seeked] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.ended] + '" style="' + eventStyle + '"></div>'
|
||||
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.loadeddata] + '" style="clear:left;' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.loadedmetadata] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.canplay] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.canplaythrough] + '" style="' + eventStyle + '"></div>'
|
||||
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.suspend] + '" style="clear:left;' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.abort] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.emptied] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.stalled] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.ratechange] + '" style="' + eventStyle + '"></div>'
|
||||
+ '<div id="' + config.eventId[$.jPlayer.event.durationchange] + '" style="' + eventStyle + '"></div>'
|
||||
|
||||
+ '<div style="clear:both"></div>';
|
||||
|
||||
// MJP: Would like a check here in case we missed an event.
|
||||
|
||||
// MJP: Check fails, since it is not on the page yet.
|
||||
/* $.each($.jPlayer.event, function(eventName,eventType) {
|
||||
if($("#" + config.eventId[eventType])[0] === undefined) {
|
||||
structure += '<div id="' + config.eventId[eventType] + '" style="clear:left;' + eventStyle + '">' + eventName + '</div>';
|
||||
}
|
||||
});
|
||||
*/
|
||||
structure +=
|
||||
'</div>'
|
||||
+ '<p><a href="#" id="' + config.updateId + '">Update</a> jPlayer Inspector</p>'
|
||||
+ '<div id="' + config.configId + '"></div>'
|
||||
+ '</div>';
|
||||
$(this).html(structure);
|
||||
|
||||
config.windowJq = $("#" + config.windowId);
|
||||
config.statusJq = $("#" + config.statusId);
|
||||
config.configJq = $("#" + config.configId);
|
||||
config.toggleJq = $("#" + config.toggleId);
|
||||
config.eventResetJq = $("#" + config.eventResetId);
|
||||
config.updateJq = $("#" + config.updateId);
|
||||
|
||||
$.each($.jPlayer.event, function(eventName,eventType) {
|
||||
config.eventJq[eventType] = $("#" + config.eventId[eventType]);
|
||||
config.eventJq[eventType].text(eventName + " (" + config.eventOccurrence[eventType] + ")"); // Sets the text to the event name and (0);
|
||||
|
||||
config.jPlayer.bind(eventType + ".jPlayerInspector", function(e) {
|
||||
config.eventOccurrence[e.type]++;
|
||||
if(config.eventOccurrence[e.type] > 1) {
|
||||
config.eventJq[e.type].css("background-color","#ff9");
|
||||
} else {
|
||||
config.eventJq[e.type].css("background-color","#9f9");
|
||||
}
|
||||
config.eventJq[e.type].text(eventName + " (" + config.eventOccurrence[e.type] + ")");
|
||||
// The timer to handle the color
|
||||
clearTimeout(config.eventTimeout[e.type]);
|
||||
config.eventTimeout[e.type] = setTimeout(function() {
|
||||
config.eventJq[e.type].css("background-color","#fff");
|
||||
}, 1000);
|
||||
// The timer to handle the occurences.
|
||||
setTimeout(function() {
|
||||
config.eventOccurrence[e.type]--;
|
||||
config.eventJq[e.type].text(eventName + " (" + config.eventOccurrence[e.type] + ")");
|
||||
}, 1000);
|
||||
if(config.visible) { // Update the status, if inspector open.
|
||||
$this.jPlayerInspector("updateStatus");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
config.jPlayer.bind($.jPlayer.event.ready + ".jPlayerInspector", function(e) {
|
||||
$this.jPlayerInspector("updateConfig");
|
||||
});
|
||||
|
||||
config.toggleJq.click(function() {
|
||||
if(config.visible) {
|
||||
$(this).text("Show");
|
||||
config.windowJq.hide();
|
||||
config.statusJq.empty();
|
||||
config.configJq.empty();
|
||||
} else {
|
||||
$(this).text("Hide");
|
||||
config.windowJq.show();
|
||||
config.updateJq.click();
|
||||
}
|
||||
config.visible = !config.visible;
|
||||
$(this).blur();
|
||||
return false;
|
||||
});
|
||||
|
||||
config.eventResetJq.click(function() {
|
||||
$.each($.jPlayer.event, function(eventName,eventType) {
|
||||
config.eventJq[eventType].css("background-color","#eee");
|
||||
});
|
||||
$(this).blur();
|
||||
return false;
|
||||
});
|
||||
|
||||
config.updateJq.click(function() {
|
||||
$this.jPlayerInspector("updateStatus");
|
||||
$this.jPlayerInspector("updateConfig");
|
||||
return false;
|
||||
});
|
||||
|
||||
if(!config.visible) {
|
||||
config.windowJq.hide();
|
||||
} else {
|
||||
// config.updateJq.click();
|
||||
}
|
||||
|
||||
$.jPlayerInspector.i++;
|
||||
|
||||
return this;
|
||||
},
|
||||
destroy: function() {
|
||||
$(this).data("jPlayerInspector") && $(this).data("jPlayerInspector").jPlayer.unbind(".jPlayerInspector");
|
||||
$(this).empty();
|
||||
},
|
||||
updateConfig: function() { // This displays information about jPlayer's configuration in inspector
|
||||
|
||||
var jPlayerInfo = "<p>This jPlayer instance is running in your browser where:<br />"
|
||||
|
||||
for(i = 0; i < $(this).data("jPlayerInspector").jPlayer.data("jPlayer").solutions.length; i++) {
|
||||
var solution = $(this).data("jPlayerInspector").jPlayer.data("jPlayer").solutions[i];
|
||||
jPlayerInfo += " jPlayer's <strong>" + solution + "</strong> solution is";
|
||||
if($(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].used) {
|
||||
jPlayerInfo += " being <strong>used</strong> and will support:<strong>";
|
||||
for(format in $(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].support) {
|
||||
if($(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].support[format]) {
|
||||
jPlayerInfo += " " + format;
|
||||
}
|
||||
}
|
||||
jPlayerInfo += "</strong><br />";
|
||||
} else {
|
||||
jPlayerInfo += " <strong>not required</strong><br />";
|
||||
}
|
||||
}
|
||||
jPlayerInfo += "</p>";
|
||||
|
||||
if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.active) {
|
||||
if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").flash.active) {
|
||||
jPlayerInfo += "<strong>Problem with jPlayer since both HTML5 and Flash are active.</strong>";
|
||||
} else {
|
||||
jPlayerInfo += "The <strong>HTML5 is active</strong>.";
|
||||
}
|
||||
} else {
|
||||
if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").flash.active) {
|
||||
jPlayerInfo += "The <strong>Flash is active</strong>.";
|
||||
} else {
|
||||
jPlayerInfo += "No solution is currently active. jPlayer needs a setMedia().";
|
||||
}
|
||||
}
|
||||
jPlayerInfo += "</p>";
|
||||
|
||||
var formatType = $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.formatType;
|
||||
jPlayerInfo += "<p><code>status.formatType = '" + formatType + "'</code><br />";
|
||||
if(formatType) {
|
||||
jPlayerInfo += "<code>Browser canPlay('" + $.jPlayer.prototype.format[formatType].codec + "')</code>";
|
||||
} else {
|
||||
jPlayerInfo += "</p>";
|
||||
}
|
||||
|
||||
jPlayerInfo += "<p><code>status.src = '" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.src + "'</code></p>";
|
||||
|
||||
jPlayerInfo += "<p><code>status.media = {<br />";
|
||||
for(prop in $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.media) {
|
||||
jPlayerInfo += " " + prop + ": " + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.media[prop] + "<br />"; // Some are strings
|
||||
}
|
||||
jPlayerInfo += "};</code></p>"
|
||||
|
||||
+ "<p>Raw browser test for HTML5 support. Should equal a function if HTML5 is available.<br />";
|
||||
if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.audio.available) {
|
||||
jPlayerInfo += "<code>htmlElement.audio.canPlayType = " + (typeof $(this).data("jPlayerInspector").jPlayer.data("jPlayer").htmlElement.audio.canPlayType) +"</code><br />"
|
||||
}
|
||||
if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.video.available) {
|
||||
jPlayerInfo += "<code>htmlElement.video.canPlayType = " + (typeof $(this).data("jPlayerInspector").jPlayer.data("jPlayer").htmlElement.video.canPlayType) +"</code>";
|
||||
}
|
||||
jPlayerInfo += "</p>";
|
||||
|
||||
jPlayerInfo += "<p>This instance is using the constructor options:<br />"
|
||||
+ "<code>$('#" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").internal.self.id + "').jPlayer({<br />"
|
||||
|
||||
+ " swfPath: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "swfPath") + "',<br />"
|
||||
|
||||
+ " solution: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "solution") + "',<br />"
|
||||
|
||||
+ " supplied: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "supplied") + "',<br />"
|
||||
|
||||
+ " preload: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "preload") + "',<br />"
|
||||
|
||||
+ " volume: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "volume") + ",<br />"
|
||||
|
||||
+ " muted: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "muted") + ",<br />"
|
||||
|
||||
+ " backgroundColor: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "backgroundColor") + "',<br />"
|
||||
|
||||
+ " cssSelectorAncestor: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelectorAncestor") + "',<br />"
|
||||
|
||||
+ " cssSelector: {";
|
||||
|
||||
var cssSelector = $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector");
|
||||
for(prop in cssSelector) {
|
||||
|
||||
// jPlayerInfo += "<br /> " + prop + ": '" + cssSelector[prop] + "'," // This works too of course, but want to use option method for deep keys.
|
||||
jPlayerInfo += "<br /> " + prop + ": '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector." + prop) + "',"
|
||||
}
|
||||
|
||||
jPlayerInfo = jPlayerInfo.slice(0, -1); // Because the sloppy comma was bugging me.
|
||||
|
||||
jPlayerInfo += "<br /> },<br />"
|
||||
|
||||
+ " errorAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "errorAlerts") + ",<br />"
|
||||
|
||||
+ " warningAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "warningAlerts") + "<br />"
|
||||
|
||||
+ "});</code></p>";
|
||||
$(this).data("jPlayerInspector").configJq.html(jPlayerInfo);
|
||||
return this;
|
||||
},
|
||||
updateStatus: function() { // This displays information about jPlayer's status in the inspector
|
||||
$(this).data("jPlayerInspector").statusJq.html(
|
||||
"<p>jPlayer is " +
|
||||
($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.paused ? "paused" : "playing") +
|
||||
" at time: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentTime*10)/10 + "s." +
|
||||
" (d: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.duration*10)/10 + "s" +
|
||||
", sp: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.seekPercent) + "%" +
|
||||
", cpr: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentRelative) + "%" +
|
||||
", cpa: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentAbsolute) + "%)</p>"
|
||||
);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
$.fn.jPlayerInspector = function( method ) {
|
||||
// Method calling logic
|
||||
if ( methods[method] ) {
|
||||
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
||||
} else if ( typeof method === 'object' || ! method ) {
|
||||
return methods.init.apply( this, arguments );
|
||||
} else {
|
||||
$.error( 'Method ' + method + ' does not exist on jQuery.jPlayerInspector' );
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* jPlayer Plugin for jQuery JavaScript Library
|
||||
* http://www.jplayer.org
|
||||
*
|
||||
* Copyright (c) 2009 - 2012 Happyworm Ltd
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* - http://www.opensource.org/licenses/mit-license.php
|
||||
* - http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* Author: Mark J Panaghiston
|
||||
* Version: 2.2.0
|
||||
* Date: 13th September 2012
|
||||
*/
|
||||
|
||||
(function(b,f){b.fn.jPlayer=function(a){var c="string"===typeof a,d=Array.prototype.slice.call(arguments,1),e=this,a=!c&&d.length?b.extend.apply(null,[!0,a].concat(d)):a;if(c&&"_"===a.charAt(0))return e;c?this.each(function(){var c=b.data(this,"jPlayer"),h=c&&b.isFunction(c[a])?c[a].apply(c,d):c;if(h!==c&&h!==f)return e=h,!1}):this.each(function(){var c=b.data(this,"jPlayer");c?c.option(a||{}):b.data(this,"jPlayer",new b.jPlayer(a,this))});return e};b.jPlayer=function(a,c){if(arguments.length){this.element=
|
||||
b(c);this.options=b.extend(!0,{},this.options,a);var d=this;this.element.bind("remove.jPlayer",function(){d.destroy()});this._init()}};b.jPlayer.emulateMethods="load play pause";b.jPlayer.emulateStatus="src readyState networkState currentTime duration paused ended playbackRate";b.jPlayer.emulateOptions="muted volume";b.jPlayer.reservedEvent="ready flashreset resize repeat error warning";b.jPlayer.event={ready:"jPlayer_ready",flashreset:"jPlayer_flashreset",resize:"jPlayer_resize",repeat:"jPlayer_repeat",
|
||||
click:"jPlayer_click",error:"jPlayer_error",warning:"jPlayer_warning",loadstart:"jPlayer_loadstart",progress:"jPlayer_progress",suspend:"jPlayer_suspend",abort:"jPlayer_abort",emptied:"jPlayer_emptied",stalled:"jPlayer_stalled",play:"jPlayer_play",pause:"jPlayer_pause",loadedmetadata:"jPlayer_loadedmetadata",loadeddata:"jPlayer_loadeddata",waiting:"jPlayer_waiting",playing:"jPlayer_playing",canplay:"jPlayer_canplay",canplaythrough:"jPlayer_canplaythrough",seeking:"jPlayer_seeking",seeked:"jPlayer_seeked",
|
||||
timeupdate:"jPlayer_timeupdate",ended:"jPlayer_ended",ratechange:"jPlayer_ratechange",durationchange:"jPlayer_durationchange",volumechange:"jPlayer_volumechange"};b.jPlayer.htmlEvent="loadstart abort emptied stalled loadedmetadata loadeddata canplay canplaythrough ratechange".split(" ");b.jPlayer.pause=function(){b.each(b.jPlayer.prototype.instances,function(a,c){c.data("jPlayer").status.srcSet&&c.jPlayer("pause")})};b.jPlayer.timeFormat={showHour:!1,showMin:!0,showSec:!0,padHour:!1,padMin:!0,padSec:!0,
|
||||
sepHour:":",sepMin:":",sepSec:""};b.jPlayer.convertTime=function(a){var c=new Date(1E3*a),d=c.getUTCHours(),a=c.getUTCMinutes(),c=c.getUTCSeconds(),d=b.jPlayer.timeFormat.padHour&&10>d?"0"+d:d,a=b.jPlayer.timeFormat.padMin&&10>a?"0"+a:a,c=b.jPlayer.timeFormat.padSec&&10>c?"0"+c:c;return(b.jPlayer.timeFormat.showHour?d+b.jPlayer.timeFormat.sepHour:"")+(b.jPlayer.timeFormat.showMin?a+b.jPlayer.timeFormat.sepMin:"")+(b.jPlayer.timeFormat.showSec?c+b.jPlayer.timeFormat.sepSec:"")};b.jPlayer.uaBrowser=
|
||||
function(a){var a=a.toLowerCase(),c=/(opera)(?:.*version)?[ \/]([\w.]+)/,b=/(msie) ([\w.]+)/,e=/(mozilla)(?:.*? rv:([\w.]+))?/,a=/(webkit)[ \/]([\w.]+)/.exec(a)||c.exec(a)||b.exec(a)||0>a.indexOf("compatible")&&e.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}};b.jPlayer.uaPlatform=function(a){var b=a.toLowerCase(),d=/(android)/,e=/(mobile)/,a=/(ipad|iphone|ipod|android|blackberry|playbook|windows ce|webos)/.exec(b)||[],b=/(ipad|playbook)/.exec(b)||!e.exec(b)&&d.exec(b)||[];a[1]&&(a[1]=a[1].replace(/\s/g,
|
||||
"_"));return{platform:a[1]||"",tablet:b[1]||""}};b.jPlayer.browser={};b.jPlayer.platform={};var i=b.jPlayer.uaBrowser(navigator.userAgent);i.browser&&(b.jPlayer.browser[i.browser]=!0,b.jPlayer.browser.version=i.version);i=b.jPlayer.uaPlatform(navigator.userAgent);i.platform&&(b.jPlayer.platform[i.platform]=!0,b.jPlayer.platform.mobile=!i.tablet,b.jPlayer.platform.tablet=!!i.tablet);b.jPlayer.prototype={count:0,version:{script:"2.2.0",needFlash:"2.2.0",flash:"unknown"},options:{swfPath:"js",solution:"html, flash",
|
||||
supplied:"mp3",preload:"metadata",volume:0.8,muted:!1,wmode:"opaque",backgroundColor:"#000000",cssSelectorAncestor:"#jp_container_1",cssSelector:{videoPlay:".jp-video-play",play:".jp-play",pause:".jp-pause",stop:".jp-stop",seekBar:".jp-seek-bar",playBar:".jp-play-bar",mute:".jp-mute",unmute:".jp-unmute",volumeBar:".jp-volume-bar",volumeBarValue:".jp-volume-bar-value",volumeMax:".jp-volume-max",currentTime:".jp-current-time",duration:".jp-duration",fullScreen:".jp-full-screen",restoreScreen:".jp-restore-screen",
|
||||
repeat:".jp-repeat",repeatOff:".jp-repeat-off",gui:".jp-gui",noSolution:".jp-no-solution"},fullScreen:!1,autohide:{restored:!1,full:!0,fadeIn:200,fadeOut:600,hold:1E3},loop:!1,repeat:function(a){a.jPlayer.options.loop?b(this).unbind(".jPlayerRepeat").bind(b.jPlayer.event.ended+".jPlayer.jPlayerRepeat",function(){b(this).jPlayer("play")}):b(this).unbind(".jPlayerRepeat")},nativeVideoControls:{},noFullScreen:{msie:/msie [0-6]/,ipad:/ipad.*?os [0-4]/,iphone:/iphone/,ipod:/ipod/,android_pad:/android [0-3](?!.*?mobile)/,
|
||||
android_phone:/android.*?mobile/,blackberry:/blackberry/,windows_ce:/windows ce/,webos:/webos/},noVolume:{ipad:/ipad/,iphone:/iphone/,ipod:/ipod/,android_pad:/android(?!.*?mobile)/,android_phone:/android.*?mobile/,blackberry:/blackberry/,windows_ce:/windows ce/,webos:/webos/,playbook:/playbook/},verticalVolume:!1,idPrefix:"jp",noConflict:"jQuery",emulateHtml:!1,errorAlerts:!1,warningAlerts:!1},optionsAudio:{size:{width:"0px",height:"0px",cssClass:""},sizeFull:{width:"0px",height:"0px",cssClass:""}},
|
||||
optionsVideo:{size:{width:"480px",height:"270px",cssClass:"jp-video-270p"},sizeFull:{width:"100%",height:"100%",cssClass:"jp-video-full"}},instances:{},status:{src:"",media:{},paused:!0,format:{},formatType:"",waitForPlay:!0,waitForLoad:!0,srcSet:!1,video:!1,seekPercent:0,currentPercentRelative:0,currentPercentAbsolute:0,currentTime:0,duration:0,readyState:0,networkState:0,playbackRate:1,ended:0},internal:{ready:!1},solution:{html:!0,flash:!0},format:{mp3:{codec:'audio/mpeg; codecs="mp3"',flashCanPlay:!0,
|
||||
media:"audio"},m4a:{codec:'audio/mp4; codecs="mp4a.40.2"',flashCanPlay:!0,media:"audio"},oga:{codec:'audio/ogg; codecs="vorbis"',flashCanPlay:!1,media:"audio"},wav:{codec:'audio/wav; codecs="1"',flashCanPlay:!1,media:"audio"},webma:{codec:'audio/webm; codecs="vorbis"',flashCanPlay:!1,media:"audio"},fla:{codec:"audio/x-flv",flashCanPlay:!0,media:"audio"},rtmpa:{codec:'audio/rtmp; codecs="rtmp"',flashCanPlay:!0,media:"audio"},m4v:{codec:'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',flashCanPlay:!0,media:"video"},
|
||||
ogv:{codec:'video/ogg; codecs="theora, vorbis"',flashCanPlay:!1,media:"video"},webmv:{codec:'video/webm; codecs="vorbis, vp8"',flashCanPlay:!1,media:"video"},flv:{codec:"video/x-flv",flashCanPlay:!0,media:"video"},rtmpv:{codec:'video/rtmp; codecs="rtmp"',flashCanPlay:!0,media:"video"}},_init:function(){var a=this;this.element.empty();this.status=b.extend({},this.status);this.internal=b.extend({},this.internal);this.internal.domNode=this.element.get(0);this.formats=[];this.solutions=[];this.require=
|
||||
{};this.htmlElement={};this.html={};this.html.audio={};this.html.video={};this.flash={};this.css={};this.css.cs={};this.css.jq={};this.ancestorJq=[];this.options.volume=this._limitValue(this.options.volume,0,1);b.each(this.options.supplied.toLowerCase().split(","),function(c,d){var e=d.replace(/^\s+|\s+$/g,"");if(a.format[e]){var f=false;b.each(a.formats,function(a,b){if(e===b){f=true;return false}});f||a.formats.push(e)}});b.each(this.options.solution.toLowerCase().split(","),function(c,d){var e=
|
||||
d.replace(/^\s+|\s+$/g,"");if(a.solution[e]){var f=false;b.each(a.solutions,function(a,b){if(e===b){f=true;return false}});f||a.solutions.push(e)}});this.internal.instance="jp_"+this.count;this.instances[this.internal.instance]=this.element;this.element.attr("id")||this.element.attr("id",this.options.idPrefix+"_jplayer_"+this.count);this.internal.self=b.extend({},{id:this.element.attr("id"),jq:this.element});this.internal.audio=b.extend({},{id:this.options.idPrefix+"_audio_"+this.count,jq:f});this.internal.video=
|
||||
b.extend({},{id:this.options.idPrefix+"_video_"+this.count,jq:f});this.internal.flash=b.extend({},{id:this.options.idPrefix+"_flash_"+this.count,jq:f,swf:this.options.swfPath+(this.options.swfPath.toLowerCase().slice(-4)!==".swf"?(this.options.swfPath&&this.options.swfPath.slice(-1)!=="/"?"/":"")+"Jplayer.swf":"")});this.internal.poster=b.extend({},{id:this.options.idPrefix+"_poster_"+this.count,jq:f});b.each(b.jPlayer.event,function(b,c){if(a.options[b]!==f){a.element.bind(c+".jPlayer",a.options[b]);
|
||||
a.options[b]=f}});this.require.audio=false;this.require.video=false;b.each(this.formats,function(b,c){a.require[a.format[c].media]=true});this.options=this.require.video?b.extend(true,{},this.optionsVideo,this.options):b.extend(true,{},this.optionsAudio,this.options);this._setSize();this.status.nativeVideoControls=this._uaBlocklist(this.options.nativeVideoControls);this.status.noFullScreen=this._uaBlocklist(this.options.noFullScreen);this.status.noVolume=this._uaBlocklist(this.options.noVolume);this._restrictNativeVideoControls();
|
||||
this.htmlElement.poster=document.createElement("img");this.htmlElement.poster.id=this.internal.poster.id;this.htmlElement.poster.onload=function(){(!a.status.video||a.status.waitForPlay)&&a.internal.poster.jq.show()};this.element.append(this.htmlElement.poster);this.internal.poster.jq=b("#"+this.internal.poster.id);this.internal.poster.jq.css({width:this.status.width,height:this.status.height});this.internal.poster.jq.hide();this.internal.poster.jq.bind("click.jPlayer",function(){a._trigger(b.jPlayer.event.click)});
|
||||
this.html.audio.available=false;if(this.require.audio){this.htmlElement.audio=document.createElement("audio");this.htmlElement.audio.id=this.internal.audio.id;this.html.audio.available=!!this.htmlElement.audio.canPlayType&&this._testCanPlayType(this.htmlElement.audio)}this.html.video.available=false;if(this.require.video){this.htmlElement.video=document.createElement("video");this.htmlElement.video.id=this.internal.video.id;this.html.video.available=!!this.htmlElement.video.canPlayType&&this._testCanPlayType(this.htmlElement.video)}this.flash.available=
|
||||
this._checkForFlash(10);this.html.canPlay={};this.flash.canPlay={};b.each(this.formats,function(b,c){a.html.canPlay[c]=a.html[a.format[c].media].available&&""!==a.htmlElement[a.format[c].media].canPlayType(a.format[c].codec);a.flash.canPlay[c]=a.format[c].flashCanPlay&&a.flash.available});this.html.desired=false;this.flash.desired=false;b.each(this.solutions,function(c,d){if(c===0)a[d].desired=true;else{var e=false,f=false;b.each(a.formats,function(b,c){a[a.solutions[0]].canPlay[c]&&(a.format[c].media===
|
||||
"video"?f=true:e=true)});a[d].desired=a.require.audio&&!e||a.require.video&&!f}});this.html.support={};this.flash.support={};b.each(this.formats,function(b,c){a.html.support[c]=a.html.canPlay[c]&&a.html.desired;a.flash.support[c]=a.flash.canPlay[c]&&a.flash.desired});this.html.used=false;this.flash.used=false;b.each(this.solutions,function(c,d){b.each(a.formats,function(b,c){if(a[d].support[c]){a[d].used=true;return false}})});this._resetActive();this._resetGate();this._cssSelectorAncestor(this.options.cssSelectorAncestor);
|
||||
if(!this.html.used&&!this.flash.used){this._error({type:b.jPlayer.error.NO_SOLUTION,context:"{solution:'"+this.options.solution+"', supplied:'"+this.options.supplied+"'}",message:b.jPlayer.errorMsg.NO_SOLUTION,hint:b.jPlayer.errorHint.NO_SOLUTION});this.css.jq.noSolution.length&&this.css.jq.noSolution.show()}else this.css.jq.noSolution.length&&this.css.jq.noSolution.hide();if(this.flash.used){var c,d="jQuery="+encodeURI(this.options.noConflict)+"&id="+encodeURI(this.internal.self.id)+"&vol="+this.options.volume+
|
||||
"&muted="+this.options.muted;if(b.jPlayer.browser.msie&&Number(b.jPlayer.browser.version)<=8){d=['<param name="movie" value="'+this.internal.flash.swf+'" />','<param name="FlashVars" value="'+d+'" />','<param name="allowScriptAccess" value="always" />','<param name="bgcolor" value="'+this.options.backgroundColor+'" />','<param name="wmode" value="'+this.options.wmode+'" />'];c=document.createElement('<object id="'+this.internal.flash.id+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="0" height="0"></object>');
|
||||
for(var e=0;e<d.length;e++)c.appendChild(document.createElement(d[e]))}else{e=function(a,b,c){var d=document.createElement("param");d.setAttribute("name",b);d.setAttribute("value",c);a.appendChild(d)};c=document.createElement("object");c.setAttribute("id",this.internal.flash.id);c.setAttribute("data",this.internal.flash.swf);c.setAttribute("type","application/x-shockwave-flash");c.setAttribute("width","1");c.setAttribute("height","1");e(c,"flashvars",d);e(c,"allowscriptaccess","always");e(c,"bgcolor",
|
||||
this.options.backgroundColor);e(c,"wmode",this.options.wmode)}this.element.append(c);this.internal.flash.jq=b(c)}if(this.html.used){if(this.html.audio.available){this._addHtmlEventListeners(this.htmlElement.audio,this.html.audio);this.element.append(this.htmlElement.audio);this.internal.audio.jq=b("#"+this.internal.audio.id)}if(this.html.video.available){this._addHtmlEventListeners(this.htmlElement.video,this.html.video);this.element.append(this.htmlElement.video);this.internal.video.jq=b("#"+this.internal.video.id);
|
||||
this.status.nativeVideoControls?this.internal.video.jq.css({width:this.status.width,height:this.status.height}):this.internal.video.jq.css({width:"0px",height:"0px"});this.internal.video.jq.bind("click.jPlayer",function(){a._trigger(b.jPlayer.event.click)})}}this.options.emulateHtml&&this._emulateHtmlBridge();this.html.used&&!this.flash.used&&setTimeout(function(){a.internal.ready=true;a.version.flash="n/a";a._trigger(b.jPlayer.event.repeat);a._trigger(b.jPlayer.event.ready)},100);this._updateNativeVideoControls();
|
||||
this._updateInterface();this._updateButtons(false);this._updateAutohide();this._updateVolume(this.options.volume);this._updateMute(this.options.muted);this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();b.jPlayer.prototype.count++},destroy:function(){this.clearMedia();this._removeUiClass();this.css.jq.currentTime.length&&this.css.jq.currentTime.text("");this.css.jq.duration.length&&this.css.jq.duration.text("");b.each(this.css.jq,function(a,b){b.length&&b.unbind(".jPlayer")});this.internal.poster.jq.unbind(".jPlayer");
|
||||
this.internal.video.jq&&this.internal.video.jq.unbind(".jPlayer");this.options.emulateHtml&&this._destroyHtmlBridge();this.element.removeData("jPlayer");this.element.unbind(".jPlayer");this.element.empty();delete this.instances[this.internal.instance]},enable:function(){},disable:function(){},_testCanPlayType:function(a){try{a.canPlayType(this.format.mp3.codec);return true}catch(b){return false}},_uaBlocklist:function(a){var c=navigator.userAgent.toLowerCase(),d=false;b.each(a,function(a,b){if(b&&
|
||||
b.test(c)){d=true;return false}});return d},_restrictNativeVideoControls:function(){if(this.require.audio&&this.status.nativeVideoControls){this.status.nativeVideoControls=false;this.status.noFullScreen=true}},_updateNativeVideoControls:function(){if(this.html.video.available&&this.html.used){this.htmlElement.video.controls=this.status.nativeVideoControls;this._updateAutohide();if(this.status.nativeVideoControls&&this.require.video){this.internal.poster.jq.hide();this.internal.video.jq.css({width:this.status.width,
|
||||
height:this.status.height})}else if(this.status.waitForPlay&&this.status.video){this.internal.poster.jq.show();this.internal.video.jq.css({width:"0px",height:"0px"})}}},_addHtmlEventListeners:function(a,c){var d=this;a.preload=this.options.preload;a.muted=this.options.muted;a.volume=this.options.volume;a.addEventListener("progress",function(){if(c.gate){d._getHtmlStatus(a);d._updateInterface();d._trigger(b.jPlayer.event.progress)}},false);a.addEventListener("timeupdate",function(){if(c.gate){d._getHtmlStatus(a);
|
||||
d._updateInterface();d._trigger(b.jPlayer.event.timeupdate)}},false);a.addEventListener("durationchange",function(){if(c.gate){d._getHtmlStatus(a);d._updateInterface();d._trigger(b.jPlayer.event.durationchange)}},false);a.addEventListener("play",function(){if(c.gate){d._updateButtons(true);d._html_checkWaitForPlay();d._trigger(b.jPlayer.event.play)}},false);a.addEventListener("playing",function(){if(c.gate){d._updateButtons(true);d._seeked();d._trigger(b.jPlayer.event.playing)}},false);a.addEventListener("pause",
|
||||
function(){if(c.gate){d._updateButtons(false);d._trigger(b.jPlayer.event.pause)}},false);a.addEventListener("waiting",function(){if(c.gate){d._seeking();d._trigger(b.jPlayer.event.waiting)}},false);a.addEventListener("seeking",function(){if(c.gate){d._seeking();d._trigger(b.jPlayer.event.seeking)}},false);a.addEventListener("seeked",function(){if(c.gate){d._seeked();d._trigger(b.jPlayer.event.seeked)}},false);a.addEventListener("volumechange",function(){if(c.gate){d.options.volume=a.volume;d.options.muted=
|
||||
a.muted;d._updateMute();d._updateVolume();d._trigger(b.jPlayer.event.volumechange)}},false);a.addEventListener("suspend",function(){if(c.gate){d._seeked();d._trigger(b.jPlayer.event.suspend)}},false);a.addEventListener("ended",function(){if(c.gate){if(!b.jPlayer.browser.webkit)d.htmlElement.media.currentTime=0;d.htmlElement.media.pause();d._updateButtons(false);d._getHtmlStatus(a,true);d._updateInterface();d._trigger(b.jPlayer.event.ended)}},false);a.addEventListener("error",function(){if(c.gate){d._updateButtons(false);
|
||||
d._seeked();if(d.status.srcSet){clearTimeout(d.internal.htmlDlyCmdId);d.status.waitForLoad=true;d.status.waitForPlay=true;d.status.video&&!d.status.nativeVideoControls&&d.internal.video.jq.css({width:"0px",height:"0px"});d._validString(d.status.media.poster)&&!d.status.nativeVideoControls&&d.internal.poster.jq.show();d.css.jq.videoPlay.length&&d.css.jq.videoPlay.show();d._error({type:b.jPlayer.error.URL,context:d.status.src,message:b.jPlayer.errorMsg.URL,hint:b.jPlayer.errorHint.URL})}}},false);b.each(b.jPlayer.htmlEvent,
|
||||
function(e,g){a.addEventListener(this,function(){c.gate&&d._trigger(b.jPlayer.event[g])},false)})},_getHtmlStatus:function(a,b){var d=0,e=0,g=0,f=0;if(isFinite(a.duration))this.status.duration=a.duration;d=a.currentTime;e=this.status.duration>0?100*d/this.status.duration:0;if(typeof a.seekable==="object"&&a.seekable.length>0){g=this.status.duration>0?100*a.seekable.end(a.seekable.length-1)/this.status.duration:100;f=this.status.duration>0?100*a.currentTime/a.seekable.end(a.seekable.length-1):0}else{g=
|
||||
100;f=e}if(b)e=f=d=0;this.status.seekPercent=g;this.status.currentPercentRelative=f;this.status.currentPercentAbsolute=e;this.status.currentTime=d;this.status.readyState=a.readyState;this.status.networkState=a.networkState;this.status.playbackRate=a.playbackRate;this.status.ended=a.ended},_resetStatus:function(){this.status=b.extend({},this.status,b.jPlayer.prototype.status)},_trigger:function(a,c,d){a=b.Event(a);a.jPlayer={};a.jPlayer.version=b.extend({},this.version);a.jPlayer.options=b.extend(true,
|
||||
{},this.options);a.jPlayer.status=b.extend(true,{},this.status);a.jPlayer.html=b.extend(true,{},this.html);a.jPlayer.flash=b.extend(true,{},this.flash);if(c)a.jPlayer.error=b.extend({},c);if(d)a.jPlayer.warning=b.extend({},d);this.element.trigger(a)},jPlayerFlashEvent:function(a,c){if(a===b.jPlayer.event.ready)if(this.internal.ready){if(this.flash.gate){if(this.status.srcSet){var d=this.status.currentTime,e=this.status.paused;this.setMedia(this.status.media);d>0&&(e?this.pause(d):this.play(d))}this._trigger(b.jPlayer.event.flashreset)}}else{this.internal.ready=
|
||||
true;this.internal.flash.jq.css({width:"0px",height:"0px"});this.version.flash=c.version;this.version.needFlash!==this.version.flash&&this._error({type:b.jPlayer.error.VERSION,context:this.version.flash,message:b.jPlayer.errorMsg.VERSION+this.version.flash,hint:b.jPlayer.errorHint.VERSION});this._trigger(b.jPlayer.event.repeat);this._trigger(a)}if(this.flash.gate)switch(a){case b.jPlayer.event.progress:this._getFlashStatus(c);this._updateInterface();this._trigger(a);break;case b.jPlayer.event.timeupdate:this._getFlashStatus(c);
|
||||
this._updateInterface();this._trigger(a);break;case b.jPlayer.event.play:this._seeked();this._updateButtons(true);this._trigger(a);break;case b.jPlayer.event.pause:this._updateButtons(false);this._trigger(a);break;case b.jPlayer.event.ended:this._updateButtons(false);this._trigger(a);break;case b.jPlayer.event.click:this._trigger(a);break;case b.jPlayer.event.error:this.status.waitForLoad=true;this.status.waitForPlay=true;this.status.video&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._validString(this.status.media.poster)&&
|
||||
this.internal.poster.jq.show();this.css.jq.videoPlay.length&&this.status.video&&this.css.jq.videoPlay.show();this.status.video?this._flash_setVideo(this.status.media):this._flash_setAudio(this.status.media);this._updateButtons(false);this._error({type:b.jPlayer.error.URL,context:c.src,message:b.jPlayer.errorMsg.URL,hint:b.jPlayer.errorHint.URL});break;case b.jPlayer.event.seeking:this._seeking();this._trigger(a);break;case b.jPlayer.event.seeked:this._seeked();this._trigger(a);break;case b.jPlayer.event.ready:break;
|
||||
default:this._trigger(a)}return false},_getFlashStatus:function(a){this.status.seekPercent=a.seekPercent;this.status.currentPercentRelative=a.currentPercentRelative;this.status.currentPercentAbsolute=a.currentPercentAbsolute;this.status.currentTime=a.currentTime;this.status.duration=a.duration;this.status.readyState=4;this.status.networkState=0;this.status.playbackRate=1;this.status.ended=false},_updateButtons:function(a){if(a!==f){this.status.paused=!a;if(this.css.jq.play.length&&this.css.jq.pause.length)if(a){this.css.jq.play.hide();
|
||||
this.css.jq.pause.show()}else{this.css.jq.play.show();this.css.jq.pause.hide()}}if(this.css.jq.restoreScreen.length&&this.css.jq.fullScreen.length)if(this.status.noFullScreen){this.css.jq.fullScreen.hide();this.css.jq.restoreScreen.hide()}else if(this.options.fullScreen){this.css.jq.fullScreen.hide();this.css.jq.restoreScreen.show()}else{this.css.jq.fullScreen.show();this.css.jq.restoreScreen.hide()}if(this.css.jq.repeat.length&&this.css.jq.repeatOff.length)if(this.options.loop){this.css.jq.repeat.hide();
|
||||
this.css.jq.repeatOff.show()}else{this.css.jq.repeat.show();this.css.jq.repeatOff.hide()}},_updateInterface:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.width(this.status.seekPercent+"%");this.css.jq.playBar.length&&this.css.jq.playBar.width(this.status.currentPercentRelative+"%");this.css.jq.currentTime.length&&this.css.jq.currentTime.text(b.jPlayer.convertTime(this.status.currentTime));this.css.jq.duration.length&&this.css.jq.duration.text(b.jPlayer.convertTime(this.status.duration))},
|
||||
_seeking:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.addClass("jp-seeking-bg")},_seeked:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.removeClass("jp-seeking-bg")},_resetGate:function(){this.html.audio.gate=false;this.html.video.gate=false;this.flash.gate=false},_resetActive:function(){this.html.active=false;this.flash.active=false},setMedia:function(a){var c=this,d=false,e=this.status.media.poster!==a.poster;this._resetMedia();this._resetGate();this._resetActive();b.each(this.formats,
|
||||
function(e,f){var i=c.format[f].media==="video";b.each(c.solutions,function(b,e){if(c[e].support[f]&&c._validString(a[f])){var g=e==="html";if(i){if(g){c.html.video.gate=true;c._html_setVideo(a);c.html.active=true}else{c.flash.gate=true;c._flash_setVideo(a);c.flash.active=true}c.css.jq.videoPlay.length&&c.css.jq.videoPlay.show();c.status.video=true}else{if(g){c.html.audio.gate=true;c._html_setAudio(a);c.html.active=true}else{c.flash.gate=true;c._flash_setAudio(a);c.flash.active=true}c.css.jq.videoPlay.length&&
|
||||
c.css.jq.videoPlay.hide();c.status.video=false}d=true;return false}});if(d)return false});if(d){if((!this.status.nativeVideoControls||!this.html.video.gate)&&this._validString(a.poster))e?this.htmlElement.poster.src=a.poster:this.internal.poster.jq.show();this.status.srcSet=true;this.status.media=b.extend({},a);this._updateButtons(false);this._updateInterface()}else this._error({type:b.jPlayer.error.NO_SUPPORT,context:"{supplied:'"+this.options.supplied+"'}",message:b.jPlayer.errorMsg.NO_SUPPORT,
|
||||
hint:b.jPlayer.errorHint.NO_SUPPORT})},_resetMedia:function(){this._resetStatus();this._updateButtons(false);this._updateInterface();this._seeked();this.internal.poster.jq.hide();clearTimeout(this.internal.htmlDlyCmdId);this.html.active?this._html_resetMedia():this.flash.active&&this._flash_resetMedia()},clearMedia:function(){this._resetMedia();this.html.active?this._html_clearMedia():this.flash.active&&this._flash_clearMedia();this._resetGate();this._resetActive()},load:function(){this.status.srcSet?
|
||||
this.html.active?this._html_load():this.flash.active&&this._flash_load():this._urlNotSetError("load")},play:function(a){a=typeof a==="number"?a:NaN;this.status.srcSet?this.html.active?this._html_play(a):this.flash.active&&this._flash_play(a):this._urlNotSetError("play")},videoPlay:function(){this.play()},pause:function(a){a=typeof a==="number"?a:NaN;this.status.srcSet?this.html.active?this._html_pause(a):this.flash.active&&this._flash_pause(a):this._urlNotSetError("pause")},pauseOthers:function(){var a=
|
||||
this;b.each(this.instances,function(b,d){a.element!==d&&d.data("jPlayer").status.srcSet&&d.jPlayer("pause")})},stop:function(){this.status.srcSet?this.html.active?this._html_pause(0):this.flash.active&&this._flash_pause(0):this._urlNotSetError("stop")},playHead:function(a){a=this._limitValue(a,0,100);this.status.srcSet?this.html.active?this._html_playHead(a):this.flash.active&&this._flash_playHead(a):this._urlNotSetError("playHead")},_muted:function(a){this.options.muted=a;this.html.used&&this._html_mute(a);
|
||||
this.flash.used&&this._flash_mute(a);if(!this.html.video.gate&&!this.html.audio.gate){this._updateMute(a);this._updateVolume(this.options.volume);this._trigger(b.jPlayer.event.volumechange)}},mute:function(a){a=a===f?true:!!a;this._muted(a)},unmute:function(a){a=a===f?true:!!a;this._muted(!a)},_updateMute:function(a){if(a===f)a=this.options.muted;if(this.css.jq.mute.length&&this.css.jq.unmute.length)if(this.status.noVolume){this.css.jq.mute.hide();this.css.jq.unmute.hide()}else if(a){this.css.jq.mute.hide();
|
||||
this.css.jq.unmute.show()}else{this.css.jq.mute.show();this.css.jq.unmute.hide()}},volume:function(a){a=this._limitValue(a,0,1);this.options.volume=a;this.html.used&&this._html_volume(a);this.flash.used&&this._flash_volume(a);if(!this.html.video.gate&&!this.html.audio.gate){this._updateVolume(a);this._trigger(b.jPlayer.event.volumechange)}},volumeBar:function(a){if(this.css.jq.volumeBar.length){var b=this.css.jq.volumeBar.offset(),d=a.pageX-b.left,e=this.css.jq.volumeBar.width(),a=this.css.jq.volumeBar.height()-
|
||||
a.pageY+b.top,b=this.css.jq.volumeBar.height();this.options.verticalVolume?this.volume(a/b):this.volume(d/e)}this.options.muted&&this._muted(false)},volumeBarValue:function(a){this.volumeBar(a)},_updateVolume:function(a){if(a===f)a=this.options.volume;a=this.options.muted?0:a;if(this.status.noVolume){this.css.jq.volumeBar.length&&this.css.jq.volumeBar.hide();this.css.jq.volumeBarValue.length&&this.css.jq.volumeBarValue.hide();this.css.jq.volumeMax.length&&this.css.jq.volumeMax.hide()}else{this.css.jq.volumeBar.length&&
|
||||
this.css.jq.volumeBar.show();if(this.css.jq.volumeBarValue.length){this.css.jq.volumeBarValue.show();this.css.jq.volumeBarValue[this.options.verticalVolume?"height":"width"](a*100+"%")}this.css.jq.volumeMax.length&&this.css.jq.volumeMax.show()}},volumeMax:function(){this.volume(1);this.options.muted&&this._muted(false)},_cssSelectorAncestor:function(a){var c=this;this.options.cssSelectorAncestor=a;this._removeUiClass();this.ancestorJq=a?b(a):[];a&&this.ancestorJq.length!==1&&this._warning({type:b.jPlayer.warning.CSS_SELECTOR_COUNT,
|
||||
context:a,message:b.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.ancestorJq.length+" found for cssSelectorAncestor.",hint:b.jPlayer.warningHint.CSS_SELECTOR_COUNT});this._addUiClass();b.each(this.options.cssSelector,function(a,b){c._cssSelector(a,b)})},_cssSelector:function(a,c){var d=this;if(typeof c==="string")if(b.jPlayer.prototype.options.cssSelector[a]){this.css.jq[a]&&this.css.jq[a].length&&this.css.jq[a].unbind(".jPlayer");this.options.cssSelector[a]=c;this.css.cs[a]=this.options.cssSelectorAncestor+
|
||||
" "+c;this.css.jq[a]=c?b(this.css.cs[a]):[];this.css.jq[a].length&&this.css.jq[a].bind("click.jPlayer",function(c){d[a](c);b(this).blur();return false});c&&this.css.jq[a].length!==1&&this._warning({type:b.jPlayer.warning.CSS_SELECTOR_COUNT,context:this.css.cs[a],message:b.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.css.jq[a].length+" found for "+a+" method.",hint:b.jPlayer.warningHint.CSS_SELECTOR_COUNT})}else this._warning({type:b.jPlayer.warning.CSS_SELECTOR_METHOD,context:a,message:b.jPlayer.warningMsg.CSS_SELECTOR_METHOD,
|
||||
hint:b.jPlayer.warningHint.CSS_SELECTOR_METHOD});else this._warning({type:b.jPlayer.warning.CSS_SELECTOR_STRING,context:c,message:b.jPlayer.warningMsg.CSS_SELECTOR_STRING,hint:b.jPlayer.warningHint.CSS_SELECTOR_STRING})},seekBar:function(a){if(this.css.jq.seekBar){var b=this.css.jq.seekBar.offset(),a=a.pageX-b.left,b=this.css.jq.seekBar.width();this.playHead(100*a/b)}},playBar:function(a){this.seekBar(a)},repeat:function(){this._loop(true)},repeatOff:function(){this._loop(false)},_loop:function(a){if(this.options.loop!==
|
||||
a){this.options.loop=a;this._updateButtons();this._trigger(b.jPlayer.event.repeat)}},currentTime:function(){},duration:function(){},gui:function(){},noSolution:function(){},option:function(a,c){var d=a;if(arguments.length===0)return b.extend(true,{},this.options);if(typeof a==="string"){var e=a.split(".");if(c===f){for(var d=b.extend(true,{},this.options),g=0;g<e.length;g++)if(d[e[g]]!==f)d=d[e[g]];else{this._warning({type:b.jPlayer.warning.OPTION_KEY,context:a,message:b.jPlayer.warningMsg.OPTION_KEY,
|
||||
hint:b.jPlayer.warningHint.OPTION_KEY});return f}return d}for(var g=d={},h=0;h<e.length;h++)if(h<e.length-1){g[e[h]]={};g=g[e[h]]}else g[e[h]]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(a,b){c._setOption(a,b)});return this},_setOption:function(a,c){var d=this;switch(a){case "volume":this.volume(c);break;case "muted":this._muted(c);break;case "cssSelectorAncestor":this._cssSelectorAncestor(c);break;case "cssSelector":b.each(c,function(a,b){d._cssSelector(a,
|
||||
b)});break;case "fullScreen":if(this.options[a]!==c){this._removeUiClass();this.options[a]=c;this._refreshSize()}break;case "size":!this.options.fullScreen&&this.options[a].cssClass!==c.cssClass&&this._removeUiClass();this.options[a]=b.extend({},this.options[a],c);this._refreshSize();break;case "sizeFull":this.options.fullScreen&&this.options[a].cssClass!==c.cssClass&&this._removeUiClass();this.options[a]=b.extend({},this.options[a],c);this._refreshSize();break;case "autohide":this.options[a]=b.extend({},
|
||||
this.options[a],c);this._updateAutohide();break;case "loop":this._loop(c);break;case "nativeVideoControls":this.options[a]=b.extend({},this.options[a],c);this.status.nativeVideoControls=this._uaBlocklist(this.options.nativeVideoControls);this._restrictNativeVideoControls();this._updateNativeVideoControls();break;case "noFullScreen":this.options[a]=b.extend({},this.options[a],c);this.status.nativeVideoControls=this._uaBlocklist(this.options.nativeVideoControls);this.status.noFullScreen=this._uaBlocklist(this.options.noFullScreen);
|
||||
this._restrictNativeVideoControls();this._updateButtons();break;case "noVolume":this.options[a]=b.extend({},this.options[a],c);this.status.noVolume=this._uaBlocklist(this.options.noVolume);this._updateVolume();this._updateMute();break;case "emulateHtml":if(this.options[a]!==c)(this.options[a]=c)?this._emulateHtmlBridge():this._destroyHtmlBridge()}return this},_refreshSize:function(){this._setSize();this._addUiClass();this._updateSize();this._updateButtons();this._updateAutohide();this._trigger(b.jPlayer.event.resize)},
|
||||
_setSize:function(){if(this.options.fullScreen){this.status.width=this.options.sizeFull.width;this.status.height=this.options.sizeFull.height;this.status.cssClass=this.options.sizeFull.cssClass}else{this.status.width=this.options.size.width;this.status.height=this.options.size.height;this.status.cssClass=this.options.size.cssClass}this.element.css({width:this.status.width,height:this.status.height})},_addUiClass:function(){this.ancestorJq.length&&this.ancestorJq.addClass(this.status.cssClass)},_removeUiClass:function(){this.ancestorJq.length&&
|
||||
this.ancestorJq.removeClass(this.status.cssClass)},_updateSize:function(){this.internal.poster.jq.css({width:this.status.width,height:this.status.height});!this.status.waitForPlay&&this.html.active&&this.status.video||this.html.video.available&&this.html.used&&this.status.nativeVideoControls?this.internal.video.jq.css({width:this.status.width,height:this.status.height}):!this.status.waitForPlay&&(this.flash.active&&this.status.video)&&this.internal.flash.jq.css({width:this.status.width,height:this.status.height})},
|
||||
_updateAutohide:function(){var a=this,b=function(){a.css.jq.gui.fadeIn(a.options.autohide.fadeIn,function(){clearTimeout(a.internal.autohideId);a.internal.autohideId=setTimeout(function(){a.css.jq.gui.fadeOut(a.options.autohide.fadeOut)},a.options.autohide.hold)})};if(this.css.jq.gui.length){this.css.jq.gui.stop(true,true);clearTimeout(this.internal.autohideId);this.element.unbind(".jPlayerAutohide");this.css.jq.gui.unbind(".jPlayerAutohide");if(this.status.nativeVideoControls)this.css.jq.gui.hide();
|
||||
else if(this.options.fullScreen&&this.options.autohide.full||!this.options.fullScreen&&this.options.autohide.restored){this.element.bind("mousemove.jPlayer.jPlayerAutohide",b);this.css.jq.gui.bind("mousemove.jPlayer.jPlayerAutohide",b);this.css.jq.gui.hide()}else this.css.jq.gui.show()}},fullScreen:function(){this._setOption("fullScreen",true)},restoreScreen:function(){this._setOption("fullScreen",false)},_html_initMedia:function(){this.htmlElement.media.src=this.status.src;this.options.preload!==
|
||||
"none"&&this._html_load();this._trigger(b.jPlayer.event.timeupdate)},_html_setAudio:function(a){var c=this;b.each(this.formats,function(b,e){if(c.html.support[e]&&a[e]){c.status.src=a[e];c.status.format[e]=true;c.status.formatType=e;return false}});this.htmlElement.media=this.htmlElement.audio;this._html_initMedia()},_html_setVideo:function(a){var c=this;b.each(this.formats,function(b,e){if(c.html.support[e]&&a[e]){c.status.src=a[e];c.status.format[e]=true;c.status.formatType=e;return false}});if(this.status.nativeVideoControls)this.htmlElement.video.poster=
|
||||
this._validString(a.poster)?a.poster:"";this.htmlElement.media=this.htmlElement.video;this._html_initMedia()},_html_resetMedia:function(){if(this.htmlElement.media){this.htmlElement.media.id===this.internal.video.id&&!this.status.nativeVideoControls&&this.internal.video.jq.css({width:"0px",height:"0px"});this.htmlElement.media.pause()}},_html_clearMedia:function(){if(this.htmlElement.media){this.htmlElement.media.src="";this.htmlElement.media.load()}},_html_load:function(){if(this.status.waitForLoad){this.status.waitForLoad=
|
||||
false;this.htmlElement.media.load()}clearTimeout(this.internal.htmlDlyCmdId)},_html_play:function(a){var b=this;this._html_load();this.htmlElement.media.play();if(!isNaN(a))try{this.htmlElement.media.currentTime=a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.play(a)},100);return}this._html_checkWaitForPlay()},_html_pause:function(a){var b=this;a>0?this._html_load():clearTimeout(this.internal.htmlDlyCmdId);this.htmlElement.media.pause();if(!isNaN(a))try{this.htmlElement.media.currentTime=
|
||||
a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.pause(a)},100);return}a>0&&this._html_checkWaitForPlay()},_html_playHead:function(a){var b=this;this._html_load();try{if(typeof this.htmlElement.media.seekable==="object"&&this.htmlElement.media.seekable.length>0)this.htmlElement.media.currentTime=a*this.htmlElement.media.seekable.end(this.htmlElement.media.seekable.length-1)/100;else if(this.htmlElement.media.duration>0&&!isNaN(this.htmlElement.media.duration))this.htmlElement.media.currentTime=
|
||||
a*this.htmlElement.media.duration/100;else throw"e";}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.playHead(a)},100);return}this.status.waitForLoad||this._html_checkWaitForPlay()},_html_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();this.internal.video.jq.css({width:this.status.width,height:this.status.height})}}},_html_volume:function(a){if(this.html.audio.available)this.htmlElement.audio.volume=
|
||||
a;if(this.html.video.available)this.htmlElement.video.volume=a},_html_mute:function(a){if(this.html.audio.available)this.htmlElement.audio.muted=a;if(this.html.video.available)this.htmlElement.video.muted=a},_flash_setAudio:function(a){var c=this;try{b.each(this.formats,function(b,d){if(c.flash.support[d]&&a[d]){switch(d){case "m4a":case "fla":c._getMovie().fl_setAudio_m4a(a[d]);break;case "mp3":c._getMovie().fl_setAudio_mp3(a[d]);break;case "rtmpa":c._getMovie().fl_setAudio_rtmp(a[d])}c.status.src=
|
||||
a[d];c.status.format[d]=true;c.status.formatType=d;return false}});if(this.options.preload==="auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_setVideo:function(a){var c=this;try{b.each(this.formats,function(b,d){if(c.flash.support[d]&&a[d]){switch(d){case "m4v":case "flv":c._getMovie().fl_setVideo_m4v(a[d]);break;case "rtmpv":c._getMovie().fl_setVideo_rtmp(a[d])}c.status.src=a[d];c.status.format[d]=true;c.status.formatType=d;return false}});if(this.options.preload===
|
||||
"auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_resetMedia:function(){this.internal.flash.jq.css({width:"0px",height:"0px"});this._flash_pause(NaN)},_flash_clearMedia:function(){try{this._getMovie().fl_clearMedia()}catch(a){this._flashError(a)}},_flash_load:function(){try{this._getMovie().fl_load()}catch(a){this._flashError(a)}this.status.waitForLoad=false},_flash_play:function(a){try{this._getMovie().fl_play(a)}catch(b){this._flashError(b)}this.status.waitForLoad=
|
||||
false;this._flash_checkWaitForPlay()},_flash_pause:function(a){try{this._getMovie().fl_pause(a)}catch(b){this._flashError(b)}if(a>0){this.status.waitForLoad=false;this._flash_checkWaitForPlay()}},_flash_playHead:function(a){try{this._getMovie().fl_play_head(a)}catch(b){this._flashError(b)}this.status.waitForLoad||this._flash_checkWaitForPlay()},_flash_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();
|
||||
this.internal.flash.jq.css({width:this.status.width,height:this.status.height})}}},_flash_volume:function(a){try{this._getMovie().fl_volume(a)}catch(b){this._flashError(b)}},_flash_mute:function(a){try{this._getMovie().fl_mute(a)}catch(b){this._flashError(b)}},_getMovie:function(){return document[this.internal.flash.id]},_checkForFlash:function(a){var b=false,d;if(window.ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+a);b=true}catch(e){}else if(navigator.plugins&&navigator.mimeTypes.length>
|
||||
0)(d=navigator.plugins["Shockwave Flash"])&&navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/,"$1")>=a&&(b=true);return b},_validString:function(a){return a&&typeof a==="string"},_limitValue:function(a,b,d){return a<b?b:a>d?d:a},_urlNotSetError:function(a){this._error({type:b.jPlayer.error.URL_NOT_SET,context:a,message:b.jPlayer.errorMsg.URL_NOT_SET,hint:b.jPlayer.errorHint.URL_NOT_SET})},_flashError:function(a){var c;c=this.internal.ready?"FLASH_DISABLED":"FLASH";this._error({type:b.jPlayer.error[c],
|
||||
context:this.internal.flash.swf,message:b.jPlayer.errorMsg[c]+a.message,hint:b.jPlayer.errorHint[c]});this.internal.flash.jq.css({width:"1px",height:"1px"})},_error:function(a){this._trigger(b.jPlayer.event.error,a);this.options.errorAlerts&&this._alert("Error!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_warning:function(a){this._trigger(b.jPlayer.event.warning,f,a);this.options.warningAlerts&&this._alert("Warning!"+(a.message?"\n\n"+a.message:"")+(a.hint?
|
||||
"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_alert:function(a){alert("jPlayer "+this.version.script+" : id='"+this.internal.self.id+"' : "+a)},_emulateHtmlBridge:function(){var a=this;b.each(b.jPlayer.emulateMethods.split(/\s+/g),function(b,d){a.internal.domNode[d]=function(b){a[d](b)}});b.each(b.jPlayer.event,function(c,d){var e=true;b.each(b.jPlayer.reservedEvent.split(/\s+/g),function(a,b){if(b===c)return e=false});e&&a.element.bind(d+".jPlayer.jPlayerHtml",function(){a._emulateHtmlUpdate();
|
||||
var b=document.createEvent("Event");b.initEvent(c,false,true);a.internal.domNode.dispatchEvent(b)})})},_emulateHtmlUpdate:function(){var a=this;b.each(b.jPlayer.emulateStatus.split(/\s+/g),function(b,d){a.internal.domNode[d]=a.status[d]});b.each(b.jPlayer.emulateOptions.split(/\s+/g),function(b,d){a.internal.domNode[d]=a.options[d]})},_destroyHtmlBridge:function(){var a=this;this.element.unbind(".jPlayerHtml");b.each((b.jPlayer.emulateMethods+" "+b.jPlayer.emulateStatus+" "+b.jPlayer.emulateOptions).split(/\s+/g),
|
||||
function(b,d){delete a.internal.domNode[d]})}};b.jPlayer.error={FLASH:"e_flash",FLASH_DISABLED:"e_flash_disabled",NO_SOLUTION:"e_no_solution",NO_SUPPORT:"e_no_support",URL:"e_url",URL_NOT_SET:"e_url_not_set",VERSION:"e_version"};b.jPlayer.errorMsg={FLASH:"jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ",FLASH_DISABLED:"jPlayer's Flash fallback has been disabled by the browser due to the CSS rules you have used. Details: ",NO_SOLUTION:"No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.",
|
||||
NO_SUPPORT:"It is not possible to play any media format provided in setMedia() on this browser using your current options.",URL:"Media URL could not be loaded.",URL_NOT_SET:"Attempt to issue media playback commands, while no media url is set.",VERSION:"jPlayer "+b.jPlayer.prototype.version.script+" needs Jplayer.swf version "+b.jPlayer.prototype.version.needFlash+" but found "};b.jPlayer.errorHint={FLASH:"Check your swfPath option and that Jplayer.swf is there.",FLASH_DISABLED:"Check that you have not display:none; the jPlayer entity or any ancestor.",
|
||||
NO_SOLUTION:"Review the jPlayer options: support and supplied.",NO_SUPPORT:"Video or audio formats defined in the supplied option are missing.",URL:"Check media URL is valid.",URL_NOT_SET:"Use setMedia() to set the media URL.",VERSION:"Update jPlayer files."};b.jPlayer.warning={CSS_SELECTOR_COUNT:"e_css_selector_count",CSS_SELECTOR_METHOD:"e_css_selector_method",CSS_SELECTOR_STRING:"e_css_selector_string",OPTION_KEY:"e_option_key"};b.jPlayer.warningMsg={CSS_SELECTOR_COUNT:"The number of css selectors found did not equal one: ",
|
||||
CSS_SELECTOR_METHOD:"The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",CSS_SELECTOR_STRING:"The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",OPTION_KEY:"The option requested in jPlayer('option') is undefined."};b.jPlayer.warningHint={CSS_SELECTOR_COUNT:"Check your css selector and the ancestor.",CSS_SELECTOR_METHOD:"Check your method name.",CSS_SELECTOR_STRING:"Check your css selector is a string.",OPTION_KEY:"Check your option name."}})(jQuery);
|
|
@ -0,0 +1,559 @@
|
|||
/*
|
||||
* jPlayer Player Plugin for Popcorn JavaScript Library
|
||||
* http://www.jplayer.org
|
||||
*
|
||||
* Copyright (c) 2012 Happyworm Ltd
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* - http://www.opensource.org/licenses/mit-license.php
|
||||
* - http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* Author: Mark J Panaghiston
|
||||
* Version: 1.0.0
|
||||
* Date: 13th September 2012
|
||||
*
|
||||
* For Popcorn Version: 1.3
|
||||
* For jPlayer Version: 2.2.0
|
||||
* Requires: jQuery 1.3.2+
|
||||
* Note: jQuery dependancy cannot be removed since jPlayer 2 is a jQuery plugin. Use of jQuery will be kept to a minimum.
|
||||
*/
|
||||
|
||||
/* Code verified using http://www.jshint.com/ */
|
||||
/*jshint asi:false, bitwise:false, boss:false, browser:true, curly:false, debug:false, devel:true, eqeqeq:true, eqnull:false, evil:false, forin:false, immed:false, jquery:true, laxbreak:false, newcap:false, noarg:true, noempty:false, nonew:true, onevar:false, passfail:false, plusplus:false, regexp:false, undef:true, sub:false, strict:false, white:false smarttabs:true */
|
||||
/*global Popcorn:false */
|
||||
|
||||
(function(Popcorn) {
|
||||
|
||||
var JQUERY_SCRIPT = 'http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js', // Used if jQuery not already present.
|
||||
JPLAYER_SCRIPT = 'http://www.jplayer.org/2.2.0/js/jquery.jplayer.min.js', // Used if jPlayer not already present.
|
||||
JPLAYER_SWFPATH = 'http://www.jplayer.org/2.2.0/js/Jplayer.swf', // Used if not specified in jPlayer options via SRC Object.
|
||||
SOLUTION = 'html,flash', // The default solution option.
|
||||
DEBUG = false, // Decided to leave the debugging option and console output in for the time being. Overhead is trivial.
|
||||
jQueryDownloading = false, // Flag to stop multiple instances from each pulling in jQuery, thus corrupting it.
|
||||
jPlayerDownloading = false, // Flag to stop multiple instances from each pulling in jPlayer, thus corrupting it.
|
||||
format = { // Duplicate of jPlayer 2.2.0 object, to avoid always requiring jQuery and jPlayer to be loaded before performing the _canPlayType() test.
|
||||
mp3: {
|
||||
codec: 'audio/mpeg; codecs="mp3"',
|
||||
flashCanPlay: true,
|
||||
media: 'audio'
|
||||
},
|
||||
m4a: { // AAC / MP4
|
||||
codec: 'audio/mp4; codecs="mp4a.40.2"',
|
||||
flashCanPlay: true,
|
||||
media: 'audio'
|
||||
},
|
||||
oga: { // OGG
|
||||
codec: 'audio/ogg; codecs="vorbis"',
|
||||
flashCanPlay: false,
|
||||
media: 'audio'
|
||||
},
|
||||
wav: { // PCM
|
||||
codec: 'audio/wav; codecs="1"',
|
||||
flashCanPlay: false,
|
||||
media: 'audio'
|
||||
},
|
||||
webma: { // WEBM
|
||||
codec: 'audio/webm; codecs="vorbis"',
|
||||
flashCanPlay: false,
|
||||
media: 'audio'
|
||||
},
|
||||
fla: { // FLV / F4A
|
||||
codec: 'audio/x-flv',
|
||||
flashCanPlay: true,
|
||||
media: 'audio'
|
||||
},
|
||||
rtmpa: { // RTMP AUDIO
|
||||
codec: 'audio/rtmp; codecs="rtmp"',
|
||||
flashCanPlay: true,
|
||||
media: 'audio'
|
||||
},
|
||||
m4v: { // H.264 / MP4
|
||||
codec: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',
|
||||
flashCanPlay: true,
|
||||
media: 'video'
|
||||
},
|
||||
ogv: { // OGG
|
||||
codec: 'video/ogg; codecs="theora, vorbis"',
|
||||
flashCanPlay: false,
|
||||
media: 'video'
|
||||
},
|
||||
webmv: { // WEBM
|
||||
codec: 'video/webm; codecs="vorbis, vp8"',
|
||||
flashCanPlay: false,
|
||||
media: 'video'
|
||||
},
|
||||
flv: { // FLV / F4V
|
||||
codec: 'video/x-flv',
|
||||
flashCanPlay: true,
|
||||
media: 'video'
|
||||
},
|
||||
rtmpv: { // RTMP VIDEO
|
||||
codec: 'video/rtmp; codecs="rtmp"',
|
||||
flashCanPlay: true,
|
||||
media: 'video'
|
||||
}
|
||||
},
|
||||
isObject = function(val) { // Basic check for Object
|
||||
if(val && typeof val === 'object' && val.hasOwnProperty) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getMediaType = function(url) { // Function to gleam the media type from the URL
|
||||
var mediaType = false;
|
||||
if(/\.mp3$/i.test(url)) {
|
||||
mediaType = 'mp3';
|
||||
} else if(/\.mp4$/i.test(url) || /\.m4v$/i.test(url)) {
|
||||
mediaType = 'm4v';
|
||||
} else if(/\.m4a$/i.test(url)) {
|
||||
mediaType = 'm4a';
|
||||
} else if(/\.ogg$/i.test(url) || /\.oga$/i.test(url)) {
|
||||
mediaType = 'oga';
|
||||
} else if(/\.ogv$/i.test(url)) {
|
||||
mediaType = 'ogv';
|
||||
} else if(/\.webm$/i.test(url)) {
|
||||
mediaType = 'webmv';
|
||||
}
|
||||
return mediaType;
|
||||
},
|
||||
getSupplied = function(url) { // Function to generate a supplied option from an src object. ie., When supplied not specified.
|
||||
var supplied = '',
|
||||
separator = '';
|
||||
if(isObject(url)) {
|
||||
// Generate supplied option from object's properties. Non-format properties would be ignored by jPlayer. Order is unpredictable.
|
||||
for(var prop in url) {
|
||||
if(url.hasOwnProperty(prop)) {
|
||||
supplied += separator + prop;
|
||||
separator = ',';
|
||||
}
|
||||
}
|
||||
}
|
||||
if(DEBUG) console.log('getSupplied(): Generated: supplied = "' + supplied + '"');
|
||||
return supplied;
|
||||
};
|
||||
|
||||
Popcorn.player( 'jplayer', {
|
||||
_canPlayType: function( containerType, url ) {
|
||||
// url : Either a String or an Object structured similar a jPlayer media object. ie., As used by setMedia in jPlayer.
|
||||
// The url object may also contain a solution and supplied property.
|
||||
|
||||
// Define the src object structure here!
|
||||
|
||||
var cType = containerType.toLowerCase(),
|
||||
srcObj = {
|
||||
media:{},
|
||||
options:{}
|
||||
},
|
||||
rVal = false, // Only a boolean false means it is not supported.
|
||||
mediaType;
|
||||
|
||||
if(cType !== 'video' && cType !== 'audio') {
|
||||
|
||||
if(typeof url === 'string') {
|
||||
// Check it starts with http, so the URL is absolute... Well, it is not a perfect check.
|
||||
if(/^http.*/i.test(url)) {
|
||||
mediaType = getMediaType(url);
|
||||
if(mediaType) {
|
||||
srcObj.media[mediaType] = url;
|
||||
srcObj.options.solution = SOLUTION;
|
||||
srcObj.options.supplied = mediaType;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
srcObj = url; // Assume the url is an src object.
|
||||
}
|
||||
|
||||
// Check for Object and appropriate minimum data structure.
|
||||
if(isObject(srcObj) && isObject(srcObj.media)) {
|
||||
|
||||
if(!isObject(srcObj.options)) {
|
||||
srcObj.options = {};
|
||||
}
|
||||
|
||||
if(!srcObj.options.solution) {
|
||||
srcObj.options.solution = SOLUTION;
|
||||
}
|
||||
|
||||
if(!srcObj.options.supplied) {
|
||||
srcObj.options.supplied = getSupplied(srcObj.media);
|
||||
}
|
||||
|
||||
// Figure out how jPlayer will play it.
|
||||
// This may not work properly when both audio and video is supplied. ie., A media player. But it should return truethy and jPlayer can figure it out.
|
||||
|
||||
var solution = srcObj.options.solution.toLowerCase().split(","), // Create the solution array, with prority based on the order of the solution string.
|
||||
supplied = srcObj.options.supplied.toLowerCase().split(","); // Create the supplied formats array, with prority based on the order of the supplied formats string.
|
||||
|
||||
for(var sol = 0; sol < solution.length; sol++) {
|
||||
|
||||
var solutionType = solution[sol].replace(/^\s+|\s+$/g, ""), //trim
|
||||
checkingHtml = solutionType === 'html',
|
||||
checkingFlash = solutionType === 'flash',
|
||||
mediaElem;
|
||||
|
||||
for(var fmt = 0; fmt < supplied.length; fmt++) {
|
||||
mediaType = supplied[fmt].replace(/^\s+|\s+$/g, ""); //trim
|
||||
if(format[mediaType]) { // Check format is valid.
|
||||
|
||||
// Create an HTML5 media element for the type of media.
|
||||
if(!mediaElem && checkingHtml) {
|
||||
mediaElem = document.createElement(format[mediaType].media);
|
||||
}
|
||||
// See if the HTML5 media element can play the MIME / Codec type.
|
||||
// Flash also returns the object if the format is playable, so it is truethy, but that html property is false.
|
||||
// This assumes Flash is available, but that should be dealt with by jPlayer if that happens.
|
||||
var htmlCanPlay = !!(mediaElem && mediaElem.canPlayType && mediaElem.canPlayType(format[mediaType].codec)),
|
||||
htmlWillPlay = htmlCanPlay && checkingHtml,
|
||||
flashWillPlay = format[mediaType].flashCanPlay && checkingFlash;
|
||||
// The first one found will match what jPlayer uses.
|
||||
if(htmlWillPlay || flashWillPlay) {
|
||||
rVal = {
|
||||
html: htmlWillPlay,
|
||||
type: mediaType
|
||||
};
|
||||
sol = solution.length; // Exit solution loop
|
||||
fmt = supplied.length; // Exit supplied loop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return rVal;
|
||||
},
|
||||
// _setup: function( options ) { // Warning: options is deprecated.
|
||||
_setup: function() {
|
||||
var media = this,
|
||||
myPlayer, // The jQuery selector of the jPlayer element. Usually a <div>
|
||||
jPlayerObj, // The jPlayer data instance. For performance and DRY code.
|
||||
mediaType = 'unknown',
|
||||
jpMedia = {},
|
||||
jpOptions = {},
|
||||
ready = false, // Used during init to override the annoying duration dependance in the track event padding during Popcorn's isReady(). ie., We is ready after loadeddata and duration can then be set real value at leisure.
|
||||
duration = 0, // For the durationchange event with both HTML5 and Flash solutions. Used with 'ready' to keep control during the Popcorn isReady() via loadeddata event. (Duration=0 is bad.)
|
||||
durationchangeId = null, // A timeout ID used with delayed durationchange event. (Because of the duration=NaN fudge to avoid Popcorn track event corruption.)
|
||||
canplaythrough = false,
|
||||
error = null, // The MediaError object.
|
||||
|
||||
dispatchDurationChange = function() {
|
||||
if(ready) {
|
||||
if(DEBUG) console.log('Dispatched event : durationchange : ' + duration);
|
||||
media.dispatchEvent('durationchange');
|
||||
} else {
|
||||
if(DEBUG) console.log('DELAYED EVENT (!ready) : durationchange : ' + duration);
|
||||
clearTimeout(durationchangeId); // Stop multiple triggers causing multiple timeouts running in parallel.
|
||||
durationchangeId = setTimeout(dispatchDurationChange, 250);
|
||||
}
|
||||
},
|
||||
|
||||
jPlayerFlashEventsPatch = function() {
|
||||
|
||||
/* Events already supported by jPlayer Flash:
|
||||
* loadstart
|
||||
* loadedmetadata (M4A, M4V)
|
||||
* progress
|
||||
* play
|
||||
* pause
|
||||
* seeking
|
||||
* seeked
|
||||
* timeupdate
|
||||
* ended
|
||||
* volumechange
|
||||
* error <- See the custom handler in jPlayerInit()
|
||||
*/
|
||||
|
||||
/* Events patched:
|
||||
* loadeddata
|
||||
* durationchange
|
||||
* canplaythrough
|
||||
* playing
|
||||
*/
|
||||
|
||||
/* Events NOT patched:
|
||||
* suspend
|
||||
* abort
|
||||
* emptied
|
||||
* stalled
|
||||
* loadedmetadata (MP3)
|
||||
* waiting
|
||||
* canplay
|
||||
* ratechange
|
||||
*/
|
||||
|
||||
// Triggering patched events through the jPlayer Object so the events are homogeneous. ie., The contain the event.jPlayer data structure.
|
||||
|
||||
var checkDuration = function(event) {
|
||||
if(event.jPlayer.status.duration !== duration) {
|
||||
duration = event.jPlayer.status.duration;
|
||||
dispatchDurationChange();
|
||||
}
|
||||
},
|
||||
|
||||
checkCanPlayThrough = function(event) {
|
||||
if(!canplaythrough && event.jPlayer.status.seekPercent === 100) {
|
||||
canplaythrough = true;
|
||||
setTimeout(function() {
|
||||
if(DEBUG) console.log('Trigger : canplaythrough');
|
||||
jPlayerObj._trigger($.jPlayer.event.canplaythrough);
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
||||
myPlayer.bind($.jPlayer.event.loadstart, function() {
|
||||
setTimeout(function() {
|
||||
if(DEBUG) console.log('Trigger : loadeddata');
|
||||
jPlayerObj._trigger($.jPlayer.event.loadeddata);
|
||||
}, 0);
|
||||
})
|
||||
.bind($.jPlayer.event.progress, function(event) {
|
||||
checkDuration(event);
|
||||
checkCanPlayThrough(event);
|
||||
})
|
||||
.bind($.jPlayer.event.timeupdate, function(event) {
|
||||
checkDuration(event);
|
||||
checkCanPlayThrough(event);
|
||||
})
|
||||
.bind($.jPlayer.event.play, function() {
|
||||
setTimeout(function() {
|
||||
if(DEBUG) console.log('Trigger : playing');
|
||||
jPlayerObj._trigger($.jPlayer.event.playing);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
if(DEBUG) console.log('Created CUSTOM event handlers for FLASH');
|
||||
},
|
||||
|
||||
jPlayerInit = function() {
|
||||
(function($) {
|
||||
|
||||
myPlayer = $('#' + media.id);
|
||||
|
||||
if(typeof media.src === 'string') {
|
||||
mediaType = getMediaType(media.src);
|
||||
jpMedia[mediaType] = media.src;
|
||||
jpOptions.supplied = mediaType;
|
||||
jpOptions.solution = SOLUTION;
|
||||
} else if(isObject(media.src)) {
|
||||
jpMedia = isObject(media.src.media) ? media.src.media : {};
|
||||
jpOptions = isObject(media.src.options) ? media.src.options : {};
|
||||
jpOptions.solution = jpOptions.solution || SOLUTION;
|
||||
jpOptions.supplied = jpOptions.supplied || getSupplied(media.src.media);
|
||||
}
|
||||
|
||||
// Allow the swfPath to be set to local server. ie., If the jPlayer Plugin is local and already on the page, then you can also use the local SWF.
|
||||
jpOptions.swfPath = jpOptions.swfPath || JPLAYER_SWFPATH;
|
||||
|
||||
myPlayer.bind($.jPlayer.event.ready, function(event) {
|
||||
if(event.jPlayer.flash.used) {
|
||||
jPlayerFlashEventsPatch();
|
||||
}
|
||||
// Set the media andd load it, so that the Flash solution behaves similar to HTML5 solution.
|
||||
// This also allows the loadstart event to be used to know jPlayer is ready.
|
||||
$(this).jPlayer('setMedia', jpMedia).jPlayer('load');
|
||||
});
|
||||
|
||||
// Do not auto-bubble the reserved events, nor the loadeddata and durationchange event, since the duration must be carefully handled when loadeddata event occurs.
|
||||
// See the duration property code for more details. (Ranting.)
|
||||
|
||||
var reservedEvents = $.jPlayer.reservedEvent + ' loadeddata durationchange',
|
||||
reservedEvent = reservedEvents.split(/\s+/g);
|
||||
|
||||
// Generate event handlers for all the standard HTML5 media events. (Except durationchange)
|
||||
|
||||
var bindEvent = function(name) {
|
||||
myPlayer.bind($.jPlayer.event[name], function(event) {
|
||||
if(DEBUG) console.log('Dispatched event: ' + name + (event && event.jPlayer ? ' (' + event.jPlayer.status.currentTime + 's)' : '')); // Must be after dispatch for some reason on Firefox/Opera
|
||||
media.dispatchEvent(name);
|
||||
});
|
||||
if(DEBUG) console.log('Created event handler for: ' + name);
|
||||
};
|
||||
|
||||
for(var eventName in $.jPlayer.event) {
|
||||
if($.jPlayer.event.hasOwnProperty(eventName)) {
|
||||
var nativeEvent = true;
|
||||
for(var iRes in reservedEvent) {
|
||||
if(reservedEvent.hasOwnProperty(iRes)) {
|
||||
if(reservedEvent[iRes] === eventName) {
|
||||
nativeEvent = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(nativeEvent) {
|
||||
bindEvent(eventName);
|
||||
} else {
|
||||
if(DEBUG) console.log('Skipped auto event handler creation for: ' + eventName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myPlayer.bind($.jPlayer.event.loadeddata, function(event) {
|
||||
if(DEBUG) console.log('Dispatched event: loadeddata' + (event && event.jPlayer ? ' (' + event.jPlayer.status.currentTime + 's)' : ''));
|
||||
media.dispatchEvent('loadeddata');
|
||||
ready = true;
|
||||
});
|
||||
if(DEBUG) console.log('Created CUSTOM event handler for: loadeddata');
|
||||
|
||||
myPlayer.bind($.jPlayer.event.durationchange, function(event) {
|
||||
duration = event.jPlayer.status.duration;
|
||||
dispatchDurationChange();
|
||||
});
|
||||
if(DEBUG) console.log('Created CUSTOM event handler for: durationchange');
|
||||
|
||||
// The error event is a special case. Plus jPlayer error event assumes it is a broken URL. (It could also be a decoder error... Or aborted or a Network error.)
|
||||
myPlayer.bind($.jPlayer.event.error, function(event) {
|
||||
// Not sure how to handle the error situation. Popcorn does not appear to have the error or error.code property documented here: http://popcornjs.org/popcorn-docs/media-methods/
|
||||
// If any error event happens, then something has gone pear shaped.
|
||||
|
||||
error = event.jPlayer.error; // Saving object pointer, not a copy of the object. Possible garbage collection issue... But the player is dead anyway, so don't care.
|
||||
|
||||
if(error.type === $.jPlayer.error.URL) {
|
||||
error.code = 4; // MEDIA_ERR_SRC_NOT_SUPPORTED since jPlayer makes this assumption. It is the most common error, then the decode error. Never seen either of the other 2 error types occur.
|
||||
} else {
|
||||
error.code = 0; // It was a jPlayer error, not an HTML5 media error.
|
||||
}
|
||||
|
||||
if(DEBUG) console.log('Dispatched event: error');
|
||||
if(DEBUG) console.dir(error);
|
||||
media.dispatchEvent('error');
|
||||
});
|
||||
if(DEBUG) console.log('Created CUSTOM event handler for: error');
|
||||
|
||||
Popcorn.player.defineProperty( media, 'error', {
|
||||
set: function() {
|
||||
// Read-only property
|
||||
return error;
|
||||
},
|
||||
get: function() {
|
||||
return error;
|
||||
}
|
||||
});
|
||||
|
||||
Popcorn.player.defineProperty( media, 'currentTime', {
|
||||
set: function( val ) {
|
||||
if(jPlayerObj.status.paused) {
|
||||
myPlayer.jPlayer('pause', val);
|
||||
} else {
|
||||
myPlayer.jPlayer('play', val);
|
||||
}
|
||||
return val;
|
||||
},
|
||||
get: function() {
|
||||
return jPlayerObj.status.currentTime;
|
||||
}
|
||||
});
|
||||
|
||||
/* The joy of duration and the loadeddata event isReady() handler
|
||||
* The duration is assumed to be a NaN or a valid duration.
|
||||
* jPlayer uses zero instead of a NaN and this screws up the Popcorn track event start/end arrays padding.
|
||||
* This line here:
|
||||
* videoDurationPlus = duration != duration ? Number.MAX_VALUE : duration + 1;
|
||||
* Not sure why it is not simply:
|
||||
* videoDurationPlus = Number.MAX_VALUE; // Who cares if the padding is close to the real duration?
|
||||
* So if you trigger loadeddata before the duration is correct, the track event padding is screwed up. (It pads the start, not the end... Well, duration+1 = 0+1 = 1s)
|
||||
* That line makes the MP3 Flash fallback difficult to setup. The whole MP3 will need to load before the duration is known.
|
||||
* Planning on using a NaN for duration until a >0 value is found... Except with MP3, where seekPercent must be 100% before setting the duration.
|
||||
* Why not just use a NaN during init... And then correct the duration later?
|
||||
*/
|
||||
|
||||
Popcorn.player.defineProperty( media, 'duration', {
|
||||
set: function() {
|
||||
// Read-only property
|
||||
if(ready) {
|
||||
return duration;
|
||||
} else {
|
||||
return NaN;
|
||||
}
|
||||
},
|
||||
get: function() {
|
||||
if(ready) {
|
||||
return duration; // Popcorn has initialized, we can now use duration zero or whatever without fear.
|
||||
} else {
|
||||
return NaN; // Keep the duration a NaN until after loadeddata event has occurred. Otherwise Popcorn track event padding is corrupted.
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Popcorn.player.defineProperty( media, 'muted', {
|
||||
set: function( val ) {
|
||||
myPlayer.jPlayer('mute', val);
|
||||
return jPlayerObj.options.muted;
|
||||
},
|
||||
get: function() {
|
||||
return jPlayerObj.options.muted;
|
||||
}
|
||||
});
|
||||
|
||||
Popcorn.player.defineProperty( media, 'volume', {
|
||||
set: function( val ) {
|
||||
myPlayer.jPlayer('volume', val);
|
||||
return jPlayerObj.options.volume;
|
||||
},
|
||||
get: function() {
|
||||
return jPlayerObj.options.volume;
|
||||
}
|
||||
});
|
||||
|
||||
Popcorn.player.defineProperty( media, 'paused', {
|
||||
set: function() {
|
||||
// Read-only property
|
||||
return jPlayerObj.status.paused;
|
||||
},
|
||||
get: function() {
|
||||
return jPlayerObj.status.paused;
|
||||
}
|
||||
});
|
||||
|
||||
media.play = function() {
|
||||
myPlayer.jPlayer('play');
|
||||
};
|
||||
media.pause = function() {
|
||||
myPlayer.jPlayer('pause');
|
||||
};
|
||||
|
||||
myPlayer.jPlayer(jpOptions); // Instance jPlayer. Note that the options should not have a ready event defined... Kill it by default?
|
||||
jPlayerObj = myPlayer.data('jPlayer');
|
||||
|
||||
}(jQuery));
|
||||
},
|
||||
|
||||
jPlayerCheck = function() {
|
||||
if (!jQuery.jPlayer) {
|
||||
if (!jPlayerDownloading) {
|
||||
jPlayerDownloading = true;
|
||||
Popcorn.getScript(JPLAYER_SCRIPT, function() {
|
||||
jPlayerDownloading = false;
|
||||
jPlayerInit();
|
||||
});
|
||||
} else {
|
||||
setTimeout(jPlayerCheck, 250);
|
||||
}
|
||||
} else {
|
||||
jPlayerInit();
|
||||
}
|
||||
},
|
||||
|
||||
jQueryCheck = function() {
|
||||
if (!window.jQuery) {
|
||||
if (!jQueryDownloading) {
|
||||
jQueryDownloading = true;
|
||||
Popcorn.getScript(JQUERY_SCRIPT, function() {
|
||||
jQueryDownloading = false;
|
||||
jPlayerCheck();
|
||||
});
|
||||
} else {
|
||||
setTimeout(jQueryCheck, 250);
|
||||
}
|
||||
} else {
|
||||
jPlayerCheck();
|
||||
}
|
||||
};
|
||||
|
||||
jQueryCheck();
|
||||
},
|
||||
_teardown: function() {
|
||||
jQuery('#' + this.id).jPlayer('destroy');
|
||||
}
|
||||
});
|
||||
|
||||
}(Popcorn));
|
After Width: | Height: | Size: 111 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.7 KiB |