无法在soundcloud中播放/暂停

时间:2018-03-28 13:11:12

标签: javascript soundcloud

我们希望在列表中点击的任何曲目中保留iframe的状态。但     我们无法两次调用播放/暂停事件。当READY事件触发时,第一次调用播放/暂停事件。

我们正在使用标志来嵌入iframe urlend,我们将重置iframe的播放/暂停事件,id =“soundcloud_widget”,如下面javascript代码中所述。

  

HTML:

<div class="player-container">
 <div class="player-top">
    <iframe id="soundcloud_widget"  name="someFrame" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/420638724%3Fsecret_token%3Ds-g3rwu&amp;color=e13a7b&amp;auto_play=true&amp;show_user=false&amp;download=false&amp;show_artwork=false" width="420" height="120" frameborder="no" scrolling="no"></iframe>
 </div>              
  <div class="song-header">
      <div class="col-xs-9">Track</div>
      <div class="col-xs-3 tac pl">Duration</div>
  </div>
  <div class="songs-container" id="musicli">                          
    <div class="songs">
       <div class="col-xs-9">
       <a class ="mp3list"  href="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/420638724%3Fsecret_token%3Ds-g3rwu&amp;color=e13a7b"        target="soundcloud_widget">Jagat Kalyani Bhavana</a></div>
       <div class="col-xs-3 tac">2:30</div>
       </div>
    <div class="songs">
      <div class="col-xs-9">
        <a class ="mp3list" href="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/420638696%3Fsecret_token%3Ds-dZniI&amp;color=e13a7b"          target="soundcloud_widget">Dada Bhagwan na Asim Jay Jay Kar Ho</a>
      </div>
      <div class="col-xs-3 tac">3:30</div>
    </div>

  </div>                                             

</div>
  

使用Javascript:

  var iframeid = "soundcloud_widget";
  LoadWidget();
    $("a").click(function(e) {

        e.preventDefault();
        console.log(plyflg);
       if(plyflg==false){

   urlend='&amp;auto_play=false&amp;show_user=false&amp;download=false&amp;
   show_artwork=false';
           }
         else{

  urlend='&amp;auto_play=true&amp;show_user=false&amp;download=false&amp;
  show_artwork=false';

             }

        var url=$(this).attr("href")+urlend;
        $("#soundcloud_widget").attr("src", url);
    })

  function LoadWidget() {

    var widget1 = SC.Widget(document.getElementById(iframeid));
    widget1.bind(SC.Widget.Events.FINISH, function (e) {

    });

    widget1.bind(SC.Widget.Events.PLAY, function (e) {

        plyflg=true;
        console.log('play'+ plyflg);
    });

    widget1.bind(SC.Widget.Events.PAUSE, function (e) {

        plyflg=false;
         console.log('PAUSE'+ plyflg);
    });
  }

1 个答案:

答案 0 :(得分:0)

我认为您必须将 test_2=(df_x.rename(columns={0:'s'}) .join(test_1) .apply(lambda x:x.shift(-(x['s'])),axis=1) .drop(columns=['s'])) 属性添加到您的 allow="autoplay" 中,以便在调用 iframe 时不会出现以下消息。

Uncaught DOMException: The user aborted a request, soundcloud, play