在Soundcloud小部件中设置开始位置

时间:2013-09-09 08:11:06

标签: widget soundcloud

我正在使用带有以下代码的Soundcloud小部件:

iframe width="100%" height="120" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F90458315&color=429dd1&buying="false";api_seekTo(30);auto_play=false&show_artwork=true"

是否可以将歌曲的开始发布设置为特定点,因此当用户播放歌曲时,它将从1m 30开始?

1 个答案:

答案 0 :(得分:2)

我相信这是可能的。下面是一个示例代码,您可以如何做到这一点。

var iframeElement   = document.querySelector('iframe');
var widget= SC.Widget(iframeElement);
widget.bind(SC.Widget.Events.READY,function(){ //When player is ready, attach an event
    widget.bind(SC.Widget.Events.PLAY,function(){ //When song starts playing
        widget.seekTo(90000);//90 seconds from the start = 1:30 min
        widget.unbind(SC.Widget.Events.PLAY); //Remove event, to avoid problems when playing is paused and then restarted
    });
});