如何通过Soundcloud API重复一首歌

How to repeat a song by Soundcloud API

本文关键字:一首 何通过 Soundcloud API      更新时间:2023-09-26

我正在制作一个基于SoundCloud API的自定义音乐播放器。我想有一个重复按钮,所以当它被按下,当前的歌曲将被重复。据我所知,SoundCloud没有提供任何重复方法,但它有一些position()方法可以获得歌曲的当前位置。我无法使这种方法奏效。但是你有什么建议来重复当前的流行歌曲吗?

我的代码到目前为止:

function playIt(){
var sound = SC.stream("/tracks/293", function(sound){
    sound.play();
    
});
}
function repeat(){
    var sound = SC.stream("/tracks/293", function(sound){
    console.log(sound.position);
    });
}

演示:http://jsfiddle.net/danials/zcN7G/23/

任何想法?提前感谢

var repeatSong = function() {
    this.play({onfinish: repeat});
};
var sound = SC.stream("/tracks/293", function(sound){
    sound.play({onfinish: repeatSong});        
});
http://jsfiddle.net/G5RdX/1/