如何在wimpy播放器中将.xml文件设置为播放列表?

时间:2015-02-09 19:14:46

标签: xml mp3 audio-player

如何将.xml播放列表放入wimpy播放器中,我的代码适用于单个MP3,如下所示:

<div id="MyTarget">

<script>

// Create a "new" wimpy player and set the "target" option 
// to match the Target Element's "id".
var myPlayer = new wimpyPlayer({
Target: "MyTarget",           
media: "../ppa/1/101/song1.mp3",
skin: "/play/wimpy.skins/038.tsv",
startUpText : "hello" 

});

</script>
</div>

1 个答案:

答案 0 :(得分:0)

您拥有相同的代码,但不是将“media”选项设置为MP3文件,请将URL设置为XML文件:

media: "/path/to/playlist.xml",

Wimpy还允许您将Javascript直接合并到“媒体”选项中。所以你可以将javascript播放列表作为:

<!-- The DIV to put wimpy into -->
<div id="MyTarget"></div>

<script>

// A javascript playlist:
var playlist = [
    {
        file : "../song1.mp3",
        title : "Song One"
    },

    {
        file : "../song2.mp3",
        title : "Song Two",
    }
];

// Create the player
var myPlayer = new wimpyPlayer({
            target      : "MyTarget",           
            media       : playlist, // Setting the javascript "playlist" var here
            startUpText : "hello" 
});
</script>