我不是不能讓當前的歌曲信息一個js編碼所以也許這是不工作只是因爲我的無知: 作爲一個非常最近的文章中jplayer用戶發現裏面組,就可以得到當前歌曲的相關信息監聽jplayer表演事件,像這樣:Jplayer 2.2.0:使用JavaScript
$("#jquery_jplayer_1").bind($.jPlayer.event.play, function(event) {
updateCurrentTrackInfo(myPlaylist.playlist[myPlaylist.current]); // send out the media info object for the current track in the playlist
});
// custom function to update the external current track div
function updateCurrentTrackInfo(obj) {
document.getElementById('currentTrackInfo').innerHTML = '<em>Now Playing…</em><span>'+obj.title+'</span> by <span>'+obj.artist+'</span>';
}
我jplayer的JavaScript之後插入一個<script type="text/javascript"></script>
這裏面的代碼。 然後在頁面的主體中,我製作了一個<div id="currentTrackInfo"></div>
標籤。
事實是,這段代碼不適合我,div保持空白,因爲它是。 也許我的錯誤是,我必須以某種方式調用函數?
如果我要坐的歌曲時長?我將如何使用相同的代碼?因爲現在我只有標題和網址。 – Ionut