javascript - 无法使用 Soundcloud JS api 流式传输歌曲

标签 javascript soundcloud

我正在使用 soundcloud 来播放歌曲。但不知道为什么歌曲不播放。

这是Full Code

点击里面的按钮我有这个功能,这个功能在 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/

相关文章:

javascript - VueJS : Pass props inside component of component

json - 发生错误,API SoundCloud自定义播放器

php - 使用 PHP 在 SoundCloud 中创建播放列表

javascript - 使用谷歌地图(或其他一些网络和移动平台)为 6000 多个位置放置标记

javascript - Angular1.6工厂

Javascript:保存和恢复样式状态在 IE 中不起作用?

javascript - 如何通过 soundcloud.com url 获取 Soundcloud 嵌入代码

javascript - SoundCloud API - 根据系统中的 ID 创建用户配置文件

javascript - 如何使用 JavaScript 在 Node-WebKit 应用程序中从 SoundCloud 流式传输音乐?

javascript - jQuery 删除 "#"之后的部分字符串并也删除 "# "