我正在使用 soundcloud 来播放歌曲。但不知道为什么歌曲不播放。
点击里面的按钮我有这个功能,这个功能在 soundcloud docs 中给出
SC.stream('/tracks/TRACK_ID').then(function(sound){
console.log(sound); //this outputs
sound.play(); // this does not do anything
});
json_object 在控制台中返回,如下所示
t.exports {选项:对象, Controller :null,streamInfo:null,_registerPlays:true,_errorRecoveryCounts:0…}
代码中一定存在什么问题?为什么宋不播放?
最佳答案
老实说,自从我使用 API 以来已经很长时间了,所以我不确定这是否有帮助,但大约一年前我做了一些事情 which animates the speaker using tracks from Soundcloud 。您可以查看来源,我认为可能与您相关的部分可能是这样的:
var widget = SC.Widget(document.getElementById('sc-widget'));
function playStereo(){
widget.getCurrentSound(function(sound){
if(sound != null){
widget.play();
} else {
widget.pause();
}
};
关于javascript - 无法使用 Soundcloud JS api 流式传输歌曲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33852481/