循环播放多个单曲音频播放器以连续播放

发布于 2024-12-17 21:17:49 字数 2404 浏览 5 评论 0原文

我正在尝试链接音频播放器,以便当一个播放器结束时,下一首歌曲将开始播放。我将拥有无数的玩家,所以我想知道如何做到这一点。这是非常简单的代码。这是两首歌曲的示例:

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪痕残 2024-12-24 21:17:49

使用播放列表插件:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文