Solved

help me with multi jplayer

Posted on 2014-01-06
3
376 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Lazy load not working with masonry js 1 17
Html5 Index on a table 7 26
how can i make the array into an object? 4 30
jquery datepciker end date add 6 days 6 34
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

776 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