Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery SoundCloud:播放按钮_Jquery_Soundcloud - Fatal编程技术网

Jquery SoundCloud:播放按钮

Jquery SoundCloud:播放按钮,jquery,soundcloud,Jquery,Soundcloud,我只想要一个播放和停止按钮来代替SoundCloud中原来的按钮。我遵循了“小部件API”: 但它不起作用。我想我不太理解SoundCloud的操作说明 我在这里播放: HTML: JAVASCRIPT/JQUERY: $(function(){ var iframeElement = document.querySelector('iframe'); var iframeElementID = iframeElement.id; var widget1

我只想要一个播放和停止按钮来代替SoundCloud中原来的按钮。我遵循了“小部件API”:
但它不起作用。我想我不太理解SoundCloud的操作说明

我在这里播放:

HTML:

JAVASCRIPT/JQUERY:

$(function(){

    var iframeElement   = document.querySelector('iframe');
    var iframeElementID = iframeElement.id;
    var widget1         = SC.Widget("#so");
    var widget2         = SC.Widget("#so");
    // widget1 === widget2

    $("#playSound").click(function() {
        $("#so").play()
    });

    $("#stopSound").click(function() {
        $("#so").pause()
    });

})

好的,这对我有用:

JS:

Html:


它现在可以正确控制iframe播放器

这是JSBin的完整工作示例:

<!DOCTYPE HTML>
 <head>

 <meta charset="UTF-8">
  <title></title>


   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<!-- SoundCloud-->
<script type="text/javascript" src="http://w.soundcloud.com/player/api.js"></script>
    <script type="text/javascript">


    $(function(){
      var widget1 = SC.Widget("so");

        $("#playSound").click(function() {
          widget1.play();

      });  
      $("#stopSound").click(function() {
          widget1.pause();
      });      
    });
  </script> 


  <style type="text/css">
  <!--

  #so{
      position: absolute;
      top: 20px;
      left: 20px;
  }

  #playSound{
      position: absolute;
      top: 200px;
      left: 20px;
      width: 20px;
      height: 20px;
      background-color: blue;
  }

  #stopSound{
      position: absolute;
      top: 200px;
      left: 50px;
      width: 20px;
      height: 20px;
      background-color: green;
  }
  ​

  -->
  </style>
 </head>

<body>

<iframe id="so" width="100%" height="160" scrolling="no" src="http://w.soundcloud.com/player/?url=http://api.soundcloud.com/users/1539950/favorites" frameborder="0" ></iframe>

<div id="playSound"></div>
<div id="stopSound"></div>



</body>
</html>

$(函数(){
var widget1=SC.Widget(“so”);
$(“#播放声音”)。单击(函数(){
widget1.play();
});  
$(“#停止声音”)。单击(函数(){
widget1.pause();
});      
});

好的,这对我有用:

JS:

Html:


它现在可以正确控制iframe播放器

这是JSBin的完整工作示例:

<!DOCTYPE HTML>
 <head>

 <meta charset="UTF-8">
  <title></title>


   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<!-- SoundCloud-->
<script type="text/javascript" src="http://w.soundcloud.com/player/api.js"></script>
    <script type="text/javascript">


    $(function(){
      var widget1 = SC.Widget("so");

        $("#playSound").click(function() {
          widget1.play();

      });  
      $("#stopSound").click(function() {
          widget1.pause();
      });      
    });
  </script> 


  <style type="text/css">
  <!--

  #so{
      position: absolute;
      top: 20px;
      left: 20px;
  }

  #playSound{
      position: absolute;
      top: 200px;
      left: 20px;
      width: 20px;
      height: 20px;
      background-color: blue;
  }

  #stopSound{
      position: absolute;
      top: 200px;
      left: 50px;
      width: 20px;
      height: 20px;
      background-color: green;
  }
  ​

  -->
  </style>
 </head>

<body>

<iframe id="so" width="100%" height="160" scrolling="no" src="http://w.soundcloud.com/player/?url=http://api.soundcloud.com/users/1539950/favorites" frameborder="0" ></iframe>

<div id="playSound"></div>
<div id="stopSound"></div>



</body>
</html>

$(函数(){
var widget1=SC.Widget(“so”);
$(“#播放声音”)。单击(函数(){
widget1.play();
});  
$(“#停止声音”)。单击(函数(){
widget1.pause();
});      
});

抱歉,但是:您的问题到底出在哪里?您试图解决什么问题?我看到一个播放按钮和一个暂停按钮,您可能正在使用旧浏览器。至于停止按钮,我已经查看了一些文档,我找不到添加按钮的提及,所以…是的,不知道我还能说什么好吧,我知道你现在正在尝试做什么,我认为你没有按照文档告诉你的那样做。您必须按照上面的说明向页面添加脚本,然后需要使用
var w=SC.Widget($('#so').get()初始化脚本
然后播放事件中的视频,
w.play()
或者实际上您可以执行
var w=SC.Widget(“#so”)用于SC.Widget。因此,你必须按照它告诉你的那样在页面顶部包含脚本,脚本可以在这里找到:一旦你包含了脚本,你就可以用它来控制iframe。我在标题中添加了这样的内容:对不起,但是:你的问题到底在哪里?你试图解决什么?我看到一个播放按钮和一个暂停按钮,您可能正在使用旧浏览器。至于停止按钮,我已经查看了一些文档,我找不到添加按钮的提及,所以…是的,不知道我还能说什么好吧,我知道你现在正在尝试做什么,我认为你没有按照文档告诉你的那样做。您必须按照上面的说明向页面添加脚本,然后需要使用
var w=SC.Widget($('#so').get()初始化脚本
然后播放事件中的视频,
w.play()
或者实际上您可以执行
var w=SC.Widget(“#so”)用于SC.Widget。因此,你必须按照它告诉你的那样在页面顶部包含脚本,脚本可以在这里找到:一旦你包含了脚本,你就可以用它来控制iframe。我在标题中添加了这个:它可以工作!。我还是不明白你是怎么从SoundCloud的指令中得到的。我在这里尝试了一下,效果非常好:但当我在Dreamweaver中复制粘贴时,它不起作用。我不明白为什么。所以我试着用JSBin。因为它同时显示了所有的代码:知道问题出在哪里吗?@Narcís Ok我已经修复了你在JSBin中给出的版本,这是因为在文档完全加载时没有分配iframe,所以JS只是在没有准备iframe内容的情况下运行,tbh在SoundClouds上的编程有点差劲,但我想它的易用性和所有方面都很好。很好。在这里,我把这个例子留在JSBin中。如果有人需要看到它工作:非常感谢!它起作用了!。我还是不明白你是怎么从SoundCloud的指令中得到的。我在这里尝试了一下,效果非常好:但当我在Dreamweaver中复制粘贴时,它不起作用。我不明白为什么。所以我试着用JSBin。因为它同时显示了所有的代码:知道问题出在哪里吗?@Narcís Ok我已经修复了你在JSBin中给出的版本,这是因为在文档完全加载时没有分配iframe,所以JS只是在没有准备iframe内容的情况下运行,tbh在SoundClouds上的编程有点差劲,但我想它的易用性和所有方面都很好。很好。在这里,我把这个例子留在JSBin中。如果有人需要看到它工作:非常感谢!
var widget1 = SC.Widget("so");

$(function(){
    $("#playSound").click(function() {
        widget1.play();

    });

    $("#stopSound").click(function() {
        widget1.pause()
    });
})
<script type="text/javascript" src="http://w.soundcloud.com/player/api.js"></script>

<iframe id="so" width="100%" height="160" scrolling="no" src="http://w.soundcloud.com/player/?url=http://api.soundcloud.com/users/1539950/favorites" frameborder="0" ></iframe>

<div id="playSound"></div>
<div id="stopSound"></div>
<!DOCTYPE HTML>
 <head>

 <meta charset="UTF-8">
  <title></title>


   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<!-- SoundCloud-->
<script type="text/javascript" src="http://w.soundcloud.com/player/api.js"></script>
    <script type="text/javascript">


    $(function(){
      var widget1 = SC.Widget("so");

        $("#playSound").click(function() {
          widget1.play();

      });  
      $("#stopSound").click(function() {
          widget1.pause();
      });      
    });
  </script> 


  <style type="text/css">
  <!--

  #so{
      position: absolute;
      top: 20px;
      left: 20px;
  }

  #playSound{
      position: absolute;
      top: 200px;
      left: 20px;
      width: 20px;
      height: 20px;
      background-color: blue;
  }

  #stopSound{
      position: absolute;
      top: 200px;
      left: 50px;
      width: 20px;
      height: 20px;
      background-color: green;
  }
  ​

  -->
  </style>
 </head>

<body>

<iframe id="so" width="100%" height="160" scrolling="no" src="http://w.soundcloud.com/player/?url=http://api.soundcloud.com/users/1539950/favorites" frameborder="0" ></iframe>

<div id="playSound"></div>
<div id="stopSound"></div>



</body>
</html>