我正在使用soundcloud来流式传输歌曲。但我不知道为什么不播放歌曲。
这是完整的代码
点击内部按钮我有这个功能,这个功能在声音云文档中给出
SC.stream('/tracks/TRACK_ID').then(function(sound){
console.log(sound); //this outputs
sound.play(); // this does not do anything
});
json_object在控制台中返回,类似于
t.exports {options: Object, controller: null, streamInfo: null, _registerPlays: true, _errorRecoveryCounts: 0…}
代码中一定有什么问题?为什么宋没有演奏?
老实说,我已经很久没有使用API了,所以我不确定这是否有帮助,但我在一年前做了一些东西,使用Soundcloud的音轨为扬声器设置动画。你可以看看来源,我认为可能与你相关的部分可能是:
var widget = SC.Widget(document.getElementById('sc-widget'));
function playStereo(){
widget.getCurrentSound(function(sound){
if(sound != null){
widget.play();
} else {
widget.pause();
}
};