我无法弄清楚如何强迫Jplayer从中读取歌曲 一个动态的asp.net自由主义列表?
目前我有这个用于从数据库中提取歌曲列表:
<div class="jp-playlist">
<ul><asp:Literal ID="ltRadio" runat="server" /></ul>
</div>
以下JPlayer中的代码演示了如何将硬编码歌曲添加到播放列表中:
$(document).ready(function () {
new jPlayerPlaylist({
jPlayer: "#jquery_jplayer",
cssSelectorAncestor: "#jp_container_1"
}, [
{
title: "Cro Magnon Man",
mp3: "http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3",
oga: "http://www.jplayer.org/audio/ogg/TSP-01-Cro_magnon_man.ogg"
}
], {
swfPath: "js",
supplied: "oga, mp3",
wmode: "window"
});
});
问题是如何将“Literal”列表中的歌曲添加到播放列表中?
答案 0 :(得分:0)
相反,我遍历JSon Object数组并将其添加到播放列表中。
/*Create an empty JSon array*/
var jsonobj = [];
/*Loop through a given list and push it into a JSon array*/
jQuery('ul.RadioList li a').each(function (index) {
var mp3 = jsonobj.push({ 'mp3': jQuery(this).attr('href') });
var title = [];
title.push(jQuery(this).text());
jsonobj[mp3 - 1]['title'] = title;
});
var cssSelector = {
jPlayer: "#jquery_jplayer",
cssSelectorAncestor: "#jp_container_1"
};
/*An Empty Playlist*/
var playlist = [];
var options = {
swfPath: "./js",
supplied: "mp3"
};
var myPlaylist = new jPlayerPlaylist(cssSelector, playlist, options);
/*Loop through the JSon array and add it to the playlist*/
for (i = 0; i < jsonobj.length; i++) {
myPlaylist.add(jsonobj[i]);
}
答案 1 :(得分:0)
你可以简单地做到
myPlaylist = new jPlayerPlaylist({
jPlayer: "#mediaPlayer",
cssSelectorAncestor: "#jp_container"
}, playList //JSON object
, {
swfPath: "dist/jplayer",
supplied: "webmv, ogv, m4v, oga, mp3",
useStateClassSkin: true
});
你和JSON对象可以是以下元素的集合
playList.push(
{
'm4v': fileURL,
'title': "File Title,
}
);