I’m not sure how you would get a handle to the player from another script, as this script is written in an anonymous function (closure) style. It deliberately doesn’t expose any global variables to be tinkered with. Also, this script only encloses the audio functionality. Your video player is probably wrapped in a separate function, and is similarly isolated.
There’s a couple of ways I might approach fixing this. The quick and dirty way would be to declare a global variable, like window.players = , and then inside both players, append a handle to each player to that array:
window.players.push($(this).jPlayer); //not sure if this is correct, you'd need to fiddle
Then, in either of the players, you could first go through all the players in the global array and stop them:
for(var i=0; i < window.players.length; i++){
window.players[i]('stop');
};
…before issuing a (‘play’) command to the current one.
The more correct and “Prototype” way to do this would be with synthetic events (note – this is completely made-up code, and relies on the Prototype.js synthetic events; jQuery may have something similar but I’m not at all familiar with that library):
//somewhere in your player functions
this.observe('players:stop', function(evt){
this.stop();
});
//inside the start playing method
this.fire('players:stop'); //stops all players, even self
this.play(); //start this player
jQuery isn’t really my bag, so I can’t help you much further than this.
Walter
On Sep 13, 2012, at 12:13 PM, Andy wrote:
Sorry now that ive uploaded it, its line 5
Andy
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options