Aug. 21, 2009Todd
Hoping someone can help, I know this is so easy, I'm just messing up the syntax somehow. I've tried a few things but can't seem to get it working.
Basically I have three videos on my page controlled by a jquery like "tabs" interface. Think 3 videos, 3 thumbnails. Only 1 video is showing at a time. When you click a thumbnail jquery hides the active div(video) and then shows the second.
In browsers like Firefox there is no problem. But in IE, the audio from the first video continues playing when I click a second video. So I need to someone say when I click a thumbnail and show a new video, stop all videos/stop the video playing etc..
Here is the base javascript:
$(function () {
var tabContainers = $('div.tabs > div');
tabContainers.hide().filter(':first').show();
$('ul.tabNavigation a').click(function () {
tabContainers.hide();
tabContainers.filter(this.hash).show();
$('ul.tabNavigation a').removeClass('selected');
$(this).addClass('selected');
return false;
}).filter(':first').click();
});
And here is my the Javascript where I've tried integrating the stop command:
$(function () {
var tabContainers = $('div.tabs > div');
tabContainers.hide().filter(':first').show();
$('ul.tabNavigation a').click(function () {
tabContainers.hide();
tabContainers.filter(this.hash).show();
player = document.getElementById(obj['id']);
player.sendEvent('STOP');
$('ul.tabNavigation a').removeClass('selected');
$(this).addClass('selected');
return false;
}).filter(':first').click();
});
Any help appreciated.
Aug. 21, 2009Alicia
Hi, I think that as you have several reference like this:
player=document.getElementById("idplayer");
Luckily, that will help this.
Aug. 21, 2009Todd
Alicia, thanks for the tip. The problem is, each player has it's own unique id. I'm assuming your code assumes all players have an id of idplayer?
Will it break anything if I set them to all the same ID?
Aug. 21, 2009lost
Quick & Dirty — just call all three players by id, with a STOP Event.
Much more involved, keep track of or find out who is playing and stop him cold!
Oct. 29, 2009mandle
lost-
Your method does accomplish stopping all players, however now javascript errors will be thrown by any browser because the currently hidden (style="dislplay:none;") divs (tabs) are well... hidden, as in not really "present" in the DOM.
I'm struggling with this issue as well Todd.
Nov. 16, 2009Zachary Ozer
@mandle - Easy: put the stop in a try / catch block.
harder: check to see which div has display:visible (or whatever)
best: Add an event listener for time events (or player state events) and have it update a variable that keeps track of the currently playing player. When you're looking to stop it, tell that player to stop.
Here are some helpful links to learn more about the JW Player™:
Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!
If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.