Skip to content

Commit

Permalink
Added tellOthers() and param to pauseOthers(time) #139
Browse files Browse the repository at this point in the history
  • Loading branch information
thepag committed Nov 3, 2013
1 parent d341e00 commit d083b28
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions jquery.jplayer/jquery.jplayer.js
Expand Up @@ -1787,16 +1787,33 @@
this._urlNotSetError("pause");
}
},
pauseOthers: function() {
var self = this;
$.each(this.instances, function(i, element) {
if(self.element !== element) { // Do not this instance.
if(element.data("jPlayer").status.srcSet) { // Check that media is set otherwise would cause error event.
element.jPlayer("pause");
tellOthers: function(command, conditions) {
var self = this,
hasConditions = typeof conditions === 'function',
args = Array.prototype.slice.call(arguments); // Convert arguments to an Array.

if(typeof command !== 'string') { // Ignore, since no command.
return; // Return undefined to maintain chaining.
}
if(hasConditions) {
args.splice(1, 1); // Remove the conditions from the arguments
}

$.each(this.instances, function() {
// Remember that "this" is the instance's "element" in the $.each() loop.
if(self.element !== this) { // Do not tell my instance.
if(!hasConditions || conditions.call(this.data("jPlayer"), self)) {
this.jPlayer.apply(this, args);
}
}
});
},
pauseOthers: function(time) {
this.tellOthers("pause", function() {
// In the conditions function, the "this" context is the other instance's jPlayer object.
return this.status.srcSet;
}, time);
},
stop: function() {
if(this.status.srcSet) {
if(this.html.active) {
Expand Down

0 comments on commit d083b28

Please sign in to comment.