0

xml ファイルからロードされ、json に変換されるプレイリストを持つ jplayer があります。共有ボタン (プレイリストの各曲ではなく、中央のボタン) を追加しようとしていますが、共有するために URL にタイトルを追加するコードを正常に作成しましたが、パラメーターを取得する方法がわかりません。ユーザーがサイトのリンクをたどったときに、共有された曲が再生されるようにします。プレイリスト ファイル、特に選択機能を変更しています。私のサイトはローカルなので、リンクを共有することはできませんが、プレイリスト コードの変更部分を投稿することはできます。

あなたが私に与えることができる助けをありがとう!! ステフ

元のプレイリスト ファイルへのリンク

変更された選択機能:

    select: function(index) {
    $.urlParam = function(homily) {
            var results = new RegExp('[\\?&]' + homily + '=([^&#]*)').exec(window.location.href);
            return results[1] || 0;
            console.log($.urlParam('homily'));
        index = (index < 0) ? this.original.length + index : index; // Negative index relates to end of array.
        if(encodeURIComponent($.urlParam('homily')) === this.playlist[index].title) {
        this.current = this.playlist[index].title;
        $(this.cssSelector.jPlayer).jPlayer("setMedia", this.playlist[this.current]);
        } else if (0 <= index && index < this.playlist.length) {
            this.current = index;
            this._highlight(index);
            $(this.cssSelector.jPlayer).jPlayer("setMedia", this.playlist[this.current]);
        var downloadBtn=this.cssSelector.cssSelectorAncestor+' [class^="download_btn"]';
            $(downloadBtn).attr('href', encodeURIComponent(this.playlist[this.current].mp3));
            var shareBtn=this.cssSelector.cssSelectorAncestor+' [class^="share_btn"]';
            $(shareBtn).attr('href', "?homily=" + decodeURIComponent(this.playlist[this.current].title));

        } else {
            this.current = 0;           
    }
    }
    },
4

1 に答える 1

0

私の理解が正しければ、現在のメディアに基づいて URL を生成する必要があります。右?

わかりました、ここにいくつかの考えがあります:

  • JPlayerPlaylist アドオンには、現在選択/再生されているメディアのインデックスを格納する内部プロパティがありますthis.current(ここでthisは、さらにプレイリスト オブジェクトのコンテキストで使用されます)。そのオブジェクトを取得するには、にアクセスしますthis.playlist[this.current]。あなたが提供したコードのこの行に沿って、すでに何かを行っています。

  • 特定の時間のプレーヤーの状態を知りたい場合。最も簡単な方法は、プレイヤーが一時停止した場合$("#your_jPlayer_Id").data("jPlayer").status.pausedに返される にアクセスすることです。true

  • また、一時停止時にボタンを設定し、有効な URL に戻すなど、いくつかのステートメントをplayandメソッドに追加します。pausehref#play

于 2012-07-12T19:28:12.800 に答える