Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

stop all players with javascript


I an trying to stop all currently playing videos on a page where the person can play multi videos at the same time (im trying to prevent that). So i want to either stop everything on the page with one command or just the running ones, whatever is easier. I also would love to do this without listing stop functions for all 25 videos on the page. Let me know if you think you have a solution!

4 Community Answers

JW Player

User  
0 rated :

If you visit my web site, www.mirana.net and then in the experiemental section select the 3D rotating cube.

There each face of the cube(6) will play a video which you can stop using the API of the JWPlayer.

For example:

each face is instantiated with a different ID hence using the code below when the stop text is clicked it will stop the JWPlayer with an ID of div1.

bc.. onclick="$jw('div1').stop()"



*NOTE:
It is possible to have all of the cube's sides play video BUT not recommended to do so by virtue that it will create excessive CPU overhead. I suggest activating three videos then you can stop each of them by clicking on the "STOP" text.*

Hope is is helpful for you

Ethan Feldman

JW Player Support Agent  
0 rated :

Here is some code showing how to do this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <script type="text/javascript" src="http://player.longtailvideo.com/jwplayer.js"></script>
		<title>Multiple</title>
    </head>
	<body>
			<div id="container"></div>
			<script type="text/javascript">
			jwplayer("container").setup({
			file: "http://www.longtailvideo.com/jw/upload/bunny.mp4",
			image: "http://www.longtailvideo.com/jw/upload/bunny.jpg",
			height: 300,
			width: 400,
			controlbar: "bottom"
			 });
			</script>
			<div id="container2"></div>
			<script type="text/javascript">
			jwplayer("container2").setup({
			file: "http://www.longtailvideo.com/jw/upload/bunny.flv",
			image: "http://www.longtailvideo.com/jw/upload/bunny.jpg",
			height: 300,
			width: 400,
			controlbar: "bottom"
			 });
			</script>
			<div id="container3"></div>
			<script type="text/javascript">
			jwplayer("container3").setup({
			file: "http://www.longtailvideo.com/jw/upload/bunny.mov",
			image: "http://www.longtailvideo.com/jw/upload/bunny.jpg",
			height: 300,
			width: 400,
			controlbar: "bottom"
			 });
			</script>
			
			<a href="#" onclick="jwplayer('container').play();jwplayer('container2').play();jwplayer('container3').play();">
			Play All Players
			</a>
			
			<br />
			
			<a href="#" onclick="jwplayer('container').stop();jwplayer('container2').stop();jwplayer('container3').stop();">
			Stop All Players
			</a>
			
</html>

JW Player

User  
0 rated :

thats my issue I want to stop all 25 videos with one command, im guessing thats not possible

Ethan Feldman

JW Player Support Agent  
0 rated :

You would just have to manually do it like I did for my example:

<a href="#" onclick="jwplayer('container').stop();jwplayer('container2').stop();jwplayer('container3').stop();">
Stop All Players
</a>

You would have to add the other ids here.

This question has received the maximum number of answers.