我正在尝试编写一个库,使它能够更好地使用SoundCloud JavaScript SDK(http://developers.soundcloud.com/docs/api/sdks#javascript)。使用dart:js通过SoundCloud JavaScript API流式传输音频
我使用'dart:js'库和 我只使用一个类来处理代理。
class SCproxy {
JsObject proxy = context['SC'];
String client_id;
SCproxy(this.client_id) {}
initialize() {
proxy.callMethod('initialize', [client_id]);
}
stream(String track_id){
var track = new JsObject(proxy.callMethod('stream',[track_id]));
print(track); // track should be the soundmanager2 object that we can call '.play' on.
}
我是从主办此次回购是(https://github.com/darkkiero/scproxy)
,当我尝试运行我的“流”的方法出现了问题。
main() {
SCproxy SC = new SCproxy('Your SoundCloud API client_ID');
SC.initialize();
SC.stream('/tracks/111477464');
}
当我试图抓住并使用由JavaScript“SC.stream”方法返回的soundmanager2对象,飞镖编辑给了我这样的例外:
Breaking on exception: type 'ScriptElement' is not a subtype of type 'JsFunction' of 'constructor'.
我的印象是,我应该能够通过收集'SC.stream'的回调来获得soundmanager2对象的Dart JsObject,但是我不确定如何。但是我可能完全滥用'dart:js',那将是有用的信息好。
是SoundManager2的一个要求吗?如果您只想播放音乐,那么这会带来很多开销。 –