我有一個jplayer播放列表,從XML文件加載並轉換成json。我正在嘗試添加一個分享按鈕(只是一箇中央的按鈕,而不是播放列表中的每首歌曲),同時我已經成功創建了將標題添加到共享URL的代碼,但我無法弄清楚如何拉取參數關閉網址以確保當用戶關注該網站時播放共享歌曲。我正在修改播放列表文件,特別是選擇功能。我的網站是本地的,所以我不能共享鏈接,但我可以發佈播放列表代碼的修改部分。Jplayer分享按鈕 - 從URL拉參數
感謝您的任何幫助,可以給我! 斯蒂芬
Link to original playlist file
修改選擇功能:
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;
}
}
},