var current_time; var current_song_id = 0; var play_list = new jPlayerPlaylist({ jPlayer: "#jquery_jplayer_1", cssSelectorAncestor: "#jp_container_1" }, [ { mp3:"http://112.84.125.239:1230/jiangdao/8%E7%A0%94%E7%BB%8F%E6%9F%A5%E7%BB%8F/%E5%93%88%E8%AF%A5%E4%B9%A6-%E5%BA%84%E7%A5%96%E9%B2%B2/%E5%BA%84%E7%A5%96%E9%B2%B2-%E5%93%88%E8%AF%A5%E4%B9%A601.mp3", id:13338, title:"庄祖鲲-哈该书01", artist_id:0, artist:"", album_id:0, album:"庄祖鲲", cover:"" }, { mp3:"http://112.84.125.239:1230/jiangdao/8%E7%A0%94%E7%BB%8F%E6%9F%A5%E7%BB%8F/%E5%93%88%E8%AF%A5%E4%B9%A6-%E5%BA%84%E7%A5%96%E9%B2%B2/%E5%BA%84%E7%A5%96%E9%B2%B2-%E5%93%88%E8%AF%A5%E4%B9%A602.mp3", id:13339, title:"庄祖鲲-哈该书02", artist_id:0, artist:"", album_id:0, album:"庄祖鲲", cover:"" }, ],{ play: function(obj){ init_lrc(obj.jPlayer.status.media.id); }, timeupdate : function (obj){ current_time = obj.jPlayer.status.currentTime; } }); function init_lrc(song_id){ var url = "/api/music/lrc/"; var data = "id=" + song_id; $.getJSON(url,data,function(response){ if(response.result == "SUCCESS"){ $.lrc.start(response.message,function(){ return current_time; }); } }); } function start_play(url_data){ var url = "/music/player/?"; window.location.href=url+url_data; } function play(ids){ var url_data = "&ids=" + ids; start_play(url_data); } function play_album(album_id){ var url_data = "&album_id=" + album_id; start_play(url_data); } function play_box(box_id){ var url_data = "&box_id=" + box_id; start_play(url_data); } function play_book(book_id){ var url_data = "&book_id=" + book_id; start_play(url_data); } function play_favor(){ var url_data = "&favor=1"; start_play(url_data); } function play_callback(media_list){ var media_arr = []; for(var i = 0; i < media_list.length; i++){ var media = { mp3:"http://112.84.125.239:1230/jiangdao/" + media_list[i].url, id:media_list[i].id, title:media_list[i].title, artist_id:media_list[i].artist_id, artist:media_list[i].artist, album_id:media_list[i].album_id, album:media_list[i].album, cover:media_list[i].cover }; media_arr.push(media); } play_list.addList(media_arr,true); } function add(ids){ var data = "ids=" + ids; get_media_list(data,add_callback); } function add_album(album_id){ var data = "album_id=" + album_id; get_media_list(data,add_callback); } function add_callback(media_list){ var media_arr = []; for(var i = 0; i < media_list.length; i++){ var media = { mp3:"112.84.125.239:1230/jiangdao/" + media_list[i].url, id:media_list[i].id, title:media_list[i].title, artist_id:media_list[i].artist_id, artist:media_list[i].artist, album_id:media_list[i].album_id, album:media_list[i].album, cover:media_list[i].cover }; media_arr.push(media); } play_list.addList(media_arr,false); } function get_media_list(data,callback){ var url = "/api/music/song/"; $.getJSON(url,data,function(response){ if(response.result == "SUCCESS"){ callback(eval(response.message)); } }); }