2

私はjsコーダーではないので、おそらくこれは私の無知のために機能していません。jplayerユーザーグループ内のごく最近の投稿にあるように、jplayerplayイベントを聞いている現在の曲情報を次のように取得できます。

    $("#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&#8230;</em><span>'+obj.title+'</span> by <span>'+obj.artist+'</span>';
}

このコードを<script type="text/javascript"></script>jplayerjavascriptの直後に挿入しました。次に、ページの本文に<div id="currentTrackInfo"></div>タグを作成しました。

事実、このコードは私には機能していません。divはそのまま空白のままです。たぶん私の間違いは、何らかの方法で関数を呼び出さなければならないということですか?

4

2 に答える 2

4

ここでこれをチェック

jQuery("#jquery_jplayer_1").bind(jQuery.jPlayer.event.play, function (イベント)
    {   

        var current = myPlaylist.current,
        プレイリスト = myPlaylist.playlist;
        jQuery.each(プレイリスト、関数(インデックス、obj){
            もし (インデックス == 現在){
                    アラート (obj.title);

            } // 条件終了の場合
        });
    });

于 2013-02-28T11:14:07.387 に答える
0

これをチェックしてください

function add_song(){
    var current = myPlaylist.current,
        playlist = myPlaylist.playlist;
    jQuery.each(playlist, function (index, obj) {
       if (index == current) {
          alert(obj.title);
        } // if condition end
    });
 }
于 2012-10-01T08:10:57.360 に答える