2012-06-19 7 views
0

xml 파일에서로드되어 json으로 변환되는 재생 목록이있는 jplayer가 있습니다. 공유 버튼 (재생 목록의 각 노래가 아닌 중앙 버튼)을 추가하려고하는데 공유하는 URL에 제목을 추가하는 코드를 만들었지 만 매개 변수를 가져 오는 방법을 알 수는 없습니다. 사용자가 링크를 따라 사이트를 방문 할 때 공유 노래가 재생되는지 확인하기 위해 URL을 차단해야합니다. 재생 목록 파일, 특히 select 함수를 수정합니다. 내 사이트는 로컬이므로 링크를 공유 할 수 없지만 재생 목록 코드의 수정 된 부분을 게시 할 수 있습니다.Jplayer 공유 버튼 - URL에서 매개 변수 가져 오기

도움을 주셔서 감사합니다. 스테파니

Link to original playlist file

수정 된 선택 기능 : 당신은 현재 미디어를 기반으로 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;   
    } 
    } 
    }, 

답변

0

조금도. 권리?

  • JPlayerPlaylist 부가 현재의 인덱스를 저장하는 것이다, this.current (여기 this 상기 재생 목록 객체의 문맥에서 사용됨)의 내부 특성을 갖는다 : 다음

    좋아, 몇 가지 생각은 선택된/재생 된 미디어. 해당 객체를 얻으려면 this.playlist[this.current]에 액세스하십시오. 당신은 이미 코드에서이 라인을 따라 뭔가를하고 있습니다.

  • 특정 시간에 플레이어의 상태를 알고 싶다면. 가장 쉬운 방법은 플레이어가 일시 중지 된 경우 true을 반환하는 $("#your_jPlayer_Id").data("jPlayer").status.paused에 액세스하는 것입니다.

  • 은 또한 설정처럼, playpause 방법에 약간의 문을 추가 할 버튼의 href 일시 정지 및 play 다시 유효한 URL에 복원에 #합니다.

관련 문제