J播放器不改变轨道


单击

链接时 Jplayer 更改曲目时出现问题。 它仍然播放播放器的演示曲目,不播放 harry.mp3 或 harry2.mp3

<tr><td>Tracklist:</td></tr>
<script>$('#mp31').click(function()
`{  $("#jp-player").jPlayer({   ready: function () {    $(this).jPlayer("setMedia", { mp3: "/harry.mp3",    });   },   swfPath: "/js",   supplied: "mp3"  }); });` </script>
<tr><td>1. </td><td><a href="" id="mp31">Test</a>Friend</a> (Techno)</td></tr>
<script>$('#mp32').click(function(){  $("#jp-player").jPlayer({   ready: function () {    $(this).jPlayer("setMedia", { mp3: "/harry2.mp3",    });   },   swfPath: "/js",   supplied: "mp3"  }); }); </script><tr><td>2. </td><td><a href="" id="mp32">Test</a>Enemy</a> (Ambient)</td></tr>

谁能帮忙,它正在做我的头。

正中电

你有两个 jplayer 实例。根据您的方案,您应该只有一个。另外,请注意您的错别字。最后,你可以尝试这样的东西:

<tr>
    <td>Tracklist:</td>
</tr>
<tr>
    <td>1.</td>
    <td><a class="song" href="http://my-website.com/mp31.mp3" id="mp31">Test</a>Friend</a> (Techno)</td>
</tr>
<tr>
    <td>2.</td>
    <td><a class="song" href="http://my-website.com/mp32.mp3" id="mp32">Test</a>Enemy</a> (Ambient)</td>
</tr>

上面的代码向您显示了一个<a>元素列表,其中包含您要播放的mp3 url,因此,通过这种方式,您可以在单击播放器后更新播放器:

<script>
    $("#jp-player").jPlayer({
        ready: function () {
            $(this).jPlayer("setMedia", {
                mp3: "/harry.mp3"
            });
        },
        swfPath: "/js", supplied: "mp3"
    });
    $('.song').click(function (e) {
        e.preventDefault();
        // get the song url from the href attribute
        var song = $(this).attr('href');
        $("#jp-player").jPlayer({
            ready: function () {
                $(this).jPlayer("setMedia", {
                    mp3: song
                });
            },
            swfPath: "/js", supplied: "mp3"
        });
    });
</script>

最新更新