soundcloud web widget API是否已过时?

时间:2017-12-23 15:36:57

标签: javascript soundcloud

我正在尝试使用soundcloud widget API(https://developers.soundcloud.com/docs/api/html5-widget

我想获得有关集合中包含的曲目的数据。

但除了widget.getSounds()和widget.getCurrentSound之外的所有其他方法似乎都有效。

我知道getter是异步的,我正在使用回调。

另外,我发现声音对象不是一个简单的数组,所以我尝试了其他方法但是失败了..

请提供任何帮助或见解

widget
_ {}

widget.getVolume(function(ret){console.log(ret)});
_ {}
VM5139:1 50

widget.getDuration(function(ret){console.log(ret)});
_ {}
VM5164:1 255057

widget.getPosition(function(ret){console.log(ret)});
_ {}
VM5190:1 92164.92599999999

widget.getCurrentSound(function(ret){console.log(ret)});
_ {}
VM2993:3 Uncaught TypeError: currentSound.get is not a function
    at _.<anonymous> (<anonymous>:3:47)
    at m (sc.js:1)
    at w (sc.js:1)
(anonymous) @ VM2993:3
m @ sc.js:1
w @ sc.js:1

widget.getCurrentSound(function(ret){console.log(ret.title)});
_ {}
VM2993:3 Uncaught TypeError: currentSound.get is not a function
    at _.<anonymous> (<anonymous>:3:47)
    at m (sc.js:1)
    at w (sc.js:1)
(anonymous) @ VM2993:3
m @ sc.js:1
w @ sc.js:1

widget.getCurrentSound(function(ret){console.log(JSON.stringify(ret))});
_ {}
3VM2993:3 Uncaught TypeError: currentSound.get is not a function
    at _.<anonymous> (<anonymous>:3:47)
    at m (sc.js:1)
    at w (sc.js:1)
(anonymous) @ VM2993:3
m @ sc.js:1
w @ sc.js:1

widget.getCurrentSound(function(ret){console.dir(ret)});
_ {}
VM2993:3 Uncaught TypeError: currentSound.get is not a function
    at _.<anonymous> (<anonymous>:3:47)
    at m (sc.js:1)
    at w (sc.js:1)

1 个答案:

答案 0 :(得分:0)

我不知道这是怎么发生的,但现在代码工作正常。

目前,声音云服务器或API可能不稳定。

widget.getSounds()和widget.getCurrentSound()返回JSON字符串(或JS中可互换的数组)

它们的格式与https://w.soundcloud.com/player/api_playground.html

的格式相同