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;
}
}
},