Solved

help me with multi jplayer

Posted on 2014-01-06
3
374 Views
Last Modified: 2014-02-14
i have a code with 3 jplayer(see attachment) but when make it dynamic it cant play
need someone help me,
thank you
jplayer.php
0
Comment
Question by:tytdimhen
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39761891
Try this :
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>THREE PLAYERS</title>        
<link href="http://jplayer.org/css/jPlayer.css" rel="stylesheet" type="text/css" />        
<link href="http://jplayer.org/latest/skin/pink.flag/jplayer.pink.flag.css" rel="stylesheet" type="text/css" />       
<link href="http://jplayer.org/latest/skin/circle.skin/circle.player.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>    
<script type="text/javascript" src="http://jplayer.org/2.1.0/js/jquery.jplayer.min.js"></script>
<script type="text/javascript" src="http://jplayer.org/latest/js/jquery.transform2d.js"></script>
<script type="text/javascript" src="http://jplayer.org/latest/js/jquery.grab.js"></script>
<script type="text/javascript" src="http://jplayer.org/latest/js/mod.csstransforms.min.js"></script>
<script type="text/javascript" src="http://jplayer.org/latest/js/circle.player.js"></script>       
<script>
	jQuery(function($) {

		var mp3links = ['http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3', 'http://kolber.github.io/audiojs/demos/mp3/juicy.mp3', 'http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3'];

		var nb_players = $(".jp-jplayer").length;
		var nb_MP3s = mp3links.length;
		var i = 0;

		function createPlayer() {
			var mp3link = mp3links[i];
			$("#jquery_jplayer_"+i).jPlayer({
				ready: function() {
					$(this).jPlayer("setMedia", { mp3: mp3link });
					i++;
					if(i<nb_players && i<nb_MP3s) {
						createPlayer();
					}
				},
				play: function() { // To avoid both jPlayers playing together.
					$(this).jPlayer("pauseOthers");
				},
				supplied: "mp3",
				cssSelectorAncestor: "#jp_container_"+i
			});
		}

		createPlayer();

	});
</script>
</head>
<body>
<?php
for($i=0;$i<3;$i++){
?>
    <div id="jquery_jplayer_<?php echo $i?>" class="jp-jplayer"></div>
    <div class="jp-audio" id="jp_container_<?php echo $i?>">
        <div class="jp-type-single">
            <div class="jp-gui jp-interface">
                <ul class="jp-controls">
                    <li><a tabindex="1" class="jp-play" href="javascript:;" style="display: block;">play</a></li>
                    <li><a tabindex="1" class="jp-pause" href="javascript:;" style="display: none;">pause</a></li>
                    <li><a tabindex="1" class="jp-stop" href="javascript:;">stop</a></li>
                    <li><a title="unmute" tabindex="1" class="jp-unmute" href="javascript:;" style="display: none;">unmute</a></li>
                </ul>
                <div class="jp-progress">
                    <div class="jp-seek-bar" style="width: 100%;">
                        <div class="jp-play-bar" style="width: 0%;"></div>
                    </div>
                </div>
            </div>
            <div class="jp-no-solution" style="display: none;"></div>
    	</div>
    </div>	
<?php
}
?>
</body>
</html>

Open in new window

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now