循环播放多个单曲音频播放器以连续播放
我正在尝试链接音频播放器,以便当一个播放器结束时,下一首歌曲将开始播放。我将拥有无数的玩家,所以我想知道如何做到这一点。这是非常简单的代码。这是两首歌曲的示例:
<div class="container">
<!-- DJ Picture -->
<img src="Pictures/Calvinharris.jpg" class="img1" />
<div class="box">
<!-- DJ Name -->
<span class="bigroom">Calvin Harris</span>
<!-- Song Title -->
<h2>We Found Love (Chuckie Mix)</h2>
<!--Song Description(179 characters with spaces)-->
<h4>Beautiful, pounding piano stabs combined with great vocals make this track a phenomenal one. Manages to powerfully fill a massive sound-space without sounding cluttered.</h4>
<!--Song file info-->
<div class="player">
<body><a id="m12" class="audio {skin:'#010101',showVolumLevel:false,showTime:false,ogg:'MP3/Rihanna feat. Calvin Harris - We Found Love (Chuckie Extended Mix).ogg'}" href="MP3/Rihanna feat. Calvin Harris - We Found Love (Chuckie Extended Mix).mp3"></a>
</div>
</div>
</div>
<div class="container">
<!-- DJ Picture -->
<img src="Pictures/dirtyharris.jpg" class="img1" />
<div class="box">
<!-- DJ Name -->
<span class="techno"> ThreeSixty & Dirty Harris</span>
<!-- Song Title -->
<h2>Louka (Funkagenda Re-Edit)</h2>
<!--Song Description(179 characters with spaces)-->
<h4>I had to include this one since it literally took over control of me while driving the other morning. I was bouncing around in my seat like a little kid who desparately needs to use the bathroom. </h4>
<!--Song file info-->
<div class="player">
<body><a id="m11" class="audio {skin:'#010101',showVolumLevel:false,showTime:false,ogg:'MP3/ThreeSixty, Funkagenda - Loudka (Funkagenda Re-Edit).ogg'}" href="MP3/ThreeSixty, Funkagenda - Loudka (Funkagenda Re-Edit).mp3"></a>
</div>
</div>
</div>
这是我想出的 jquery,但它不起作用。
function playNext(idx){
var players=$(".audio");
document.playerIDX = idx+1 <= players.length-1 ? idx+1 : 0;
players.eq(document.playerIDX).mb_miniPlayer_play();
}
I am trying to link audio players so that when one finishes, the next song will start playing. I will have an endless number of players, so I am wondering how to do this. This is pretty straight forward code. Here is an example of two songs:
<div class="container">
<!-- DJ Picture -->
<img src="Pictures/Calvinharris.jpg" class="img1" />
<div class="box">
<!-- DJ Name -->
<span class="bigroom">Calvin Harris</span>
<!-- Song Title -->
<h2>We Found Love (Chuckie Mix)</h2>
<!--Song Description(179 characters with spaces)-->
<h4>Beautiful, pounding piano stabs combined with great vocals make this track a phenomenal one. Manages to powerfully fill a massive sound-space without sounding cluttered.</h4>
<!--Song file info-->
<div class="player">
<body><a id="m12" class="audio {skin:'#010101',showVolumLevel:false,showTime:false,ogg:'MP3/Rihanna feat. Calvin Harris - We Found Love (Chuckie Extended Mix).ogg'}" href="MP3/Rihanna feat. Calvin Harris - We Found Love (Chuckie Extended Mix).mp3"></a>
</div>
</div>
</div>
<div class="container">
<!-- DJ Picture -->
<img src="Pictures/dirtyharris.jpg" class="img1" />
<div class="box">
<!-- DJ Name -->
<span class="techno"> ThreeSixty & Dirty Harris</span>
<!-- Song Title -->
<h2>Louka (Funkagenda Re-Edit)</h2>
<!--Song Description(179 characters with spaces)-->
<h4>I had to include this one since it literally took over control of me while driving the other morning. I was bouncing around in my seat like a little kid who desparately needs to use the bathroom. </h4>
<!--Song file info-->
<div class="player">
<body><a id="m11" class="audio {skin:'#010101',showVolumLevel:false,showTime:false,ogg:'MP3/ThreeSixty, Funkagenda - Loudka (Funkagenda Re-Edit).ogg'}" href="MP3/ThreeSixty, Funkagenda - Loudka (Funkagenda Re-Edit).mp3"></a>
</div>
</div>
</div>
Here is the jquery I have come up with, but it does not work.
function playNext(idx){
var players=$(".audio");
document.playerIDX = idx+1 <= players.length-1 ? idx+1 : 0;
players.eq(document.playerIDX).mb_miniPlayer_play();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用播放列表插件:
http://www.jplayer.org/latest/demo -02-jPlayerPlaylist/
在我这边工作得很好
Use the playlist add-on:
http://www.jplayer.org/latest/demo-02-jPlayerPlaylist/
Works fine on my side