我只想要一个播放和停止按钮来替换 SoundCloud 中的原始按钮。我遵循了“Widget API”:http: //developers.soundcloud.com/docs/api/html5-widget#
但它不起作用。我想我不太了解 SoundCloud 的说明。
我在这里播放:http: //jsfiddle.net/wBTCh/1/
HTML:
<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>
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;
}
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()
});
})