How can I have multiple videos on a page with only playing one at a time?
Is there an article somewhere on how to offer multiple videos on one page, but such that only one video plays at a time? For example, let's say there are four videos. The user plays video one, but then wants to play video two instead. How can we configure it so that when the user plays video two, video one will automatically stop playing. Thanks in advance for any help.
I have several examples on my web site where there are multiple players playing a video on a page that only instantiate a single option for the JWPlayer.
The players are differentiated by their ids (ie) player1...player6 that all receive the same initial option and via the load function feature of the JWPlayer will load a different video.
My 3D cubes can and will play 6 different videos at a time.
for the JWP5 version www.starbase-alpha.com/cube4b.html
bc.. <script>
var options = { /*----------layout for player -------*/ width:'300', height:'300', /*----------behaviour for player ----*/ stretching:'fill', volume: '30', /*------------ content for player ------*/ controlbar:'none', icons: 'true', skin: 'skins/glow/glow.xml',
image:'images/first.jpg',
/*----------------- action for the player -----------*/ modes: {type: "html5"}
}; /* eof option listing for html5mode */
/*--------- instantiation of player with the option listing --------*/
for the JWP6 version www.starbase-alpha.com/beta7.html
bc.. var options =
{ /*----------layout for player -------*/ width: '300', height: '300', /*------------- behaviour for player ----*/ stretching: 'fill', autostart: 'false', controls: 'false', /*------------ content for player ------*/ image: 'images/first.jpg', /* -- the folowing is a dummy declaration for media files; they do not exist doing so prevents an error being generated by the JWPlayer -- */ sources: [ {file:'0.webm'}, {file:'0.mp4'} ], }; /*--------- instantiation of the players with the options listing --------*/ jwplayer("div1").setup(options).setMute(true); jwplayer("div2").setup(options).setMute(true); jwplayer("div3").setup(options).setMute(true); jwplayer("div4").setup(options).setMute(true); jwplayer("div5").setup(options).setMute(true); jwplayer("div6").setup(options).setMute(true);
/* this is an example of loading a video into the JWPlayer('div5')
<li><a onclick="jwplayer('div5').load({image:'images/first.jpg',sources:[{file:'video/The Best of Enigma1.webm'},{file:'video/The Best of Enigma1.mp4'}]}).play()"> <img src="video/images/bestofenigma.jpg" alt="Abbott & Costello" title="♦ Engima ‐ The Best of Enigma ♦"> </a> <span><span>Enigma</span><br>Best of Enigma</span><br> <a class="stop" title=" stop video " onclick="jwplayer('div5').stop()">Stop</a> <a class="stop" title=" switch audio on " onclick="jwplayer('div5').setMute(false)">Audio On</a> <a class="stop" title=" switch audio Off " onclick="jwplayer('div5').setMute(true)">Audio Off</a> <article class="c1"> </article> </li> */
</script>
not sure if this is helpful for you BUT it is show you that multiple videos are possible to be played on a single page. The key is the load function.
@Ethan - Thanks for the code. I was able to get it to work as-is, with your videos, but couldn't get our videos to work. I was expecting this to be a bit troublesome.
@Willie - Thanks for your suggestions. Today is my first day working with JWPlayer, so I don't know what version it is. How do I find out?
The best suggestion that I can offer may seem 'crazy' but draw your page(s) out on paper with everything you want to have to be displayed when a visitor visits that page.
A flow diagram will certainly help and the best program for that is Visio.
Doing so, it will allow you to conceptualize the web site(page[s]).
I use a white-board with different colors.
You have to decide which version to use JWP5 or JWP6 for your web site. IMHO, JWP6 is the better.
feel free to visit my web site and look at the JWP6 portal for with the examples there you'll be able to view the coding used for that particular example. www.starbase-alpha.com which you can view in fullscreen or normal screen mode.
I made some progress. The question now is how to automatically stop a video once another one is started, so that there aren't multiple videos playing at the same time.
Its not working... actually i have a page with tracks listed with its own player ... Now i want to play only one track at a time i.e if i play a new track then the other track will pause automatically!
This JW HTML Config library might be an option as it features auto-pause of all other JW Players on a page when selecting a video to play. Check out: powered-by-haiku.co.uk/?p=189
Thanks for everyone's input - I successfully implemented multiple players where each stops the others. http://www.soundsyrup.com/TEST_SITE/Dec_2010/JW_Video3.html
What I'm trying to do now is PAUSE the others - so should I return to a previous video it continues playing from where it left off.
Ethan I tried using the code you pasted at the top of this thread - and thought this snippet might enable a pause instead of a stop:
After inserting that, nothing changed, the players still stop and return to zero. Earlier I tried code that unintentionally forced all the videos to start and stop at the same time, mixing them together:
I have an example exactly that fits to the tee of what you need; my 3D rotating cube has six players and can play all at once or even pause one at a time.
My web site is currently down as I am updating it to be HTML5.1 validated which I suspect will take me till about Monday?Tuesday.
I am willing to help let me know how to contact you if you wish some help