Seemingly simple question, but I haven’t seen anything in the jwplayer javascript API that leads me to an answer.
I’m trying to loop through all instances of jwplayer objects on my page without keeping track of the number that may be on the page.
Does anyone know a way to do this?
The solution I’m using for now is:
var maxPlayers = 20;
for(var i = 0; i < maxPlayers; i++) {
if(jwplayer(i)) {
// execute code on jwplayer instance here
}
}
Thanks!
You could keep looping until
jwPlayerreturns null:Or, more tersely,