简体   繁体   English

拉JPlayer播放列表元素信息

[英]Pull JPlayer playlist element information

I'm crushing my head for days, because I can't figure out how to show in a specific div/span the JPlayer playlist's current songs tite/name? 我已经花了几天时间,因为我不知道如何在特定的div / span中显示JPlayer播放列表的当前歌曲tite / name? I'm using the code from JPlayer's demo: 我正在使用JPlayer演示中的代码:

    var playlist = new jPlayerPlaylist({
    jPlayer: "#jquery_jplayer_1",
    cssSelectorAncestor: "#jp_container_1"
    }, [
        {
            title:"Song - 1",
            mp3:"./path/to/song1.mp3"
        },
        {
            title:"Song - 2",
            mp3:"./path/to/song2.mp3"
        },
        ], {
        swfPath: "js",
        supplied: "mp3",
        wmode: "window"
    });

Thanks for your help, guys! 谢谢你们的帮助! :) :)

In your jplayer.playlist.js file add a line like the following to the _highlight function with the correct my_jquery_selector for the div you'd like the title to be printed in: 在您的jplayer.playlist.js文件中,向_highlight函数添加一条类似于以下内容的行,并为要在其中打印标题的div使用正确的my_jquery_selector

$(my_jquery_selector).html(this.playlist[index].title);

This is jacked from the current final line of that method that sets the title div ( this.cssSelector.title )in the player itself. 这是从该方法的当前最后一行开始的,该方法在播放器本身中设置标题div( this.cssSelector.title )。

There are ways to get the title to show in the player itself but that doesn't seem to be what you are asking. 有多种方法可以使标题显示在播放器本身中,但这似乎并不是您要的。 I'm assuming here that you want to show the title in some div outside the player. 我在这里假设您要在播放器外部的某个div中显示标题。

To display only the current playing track, I just did this in the stylesheet: 为了只显示当前的播放曲目,我只是在样式表中执行了此操作:

div.jp-playlist ul li {
    display:none;
}

div.jp-playlist ul li.jp-playlist-current {
    display:inline;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM