我正在嘗試編寫一個庫,使它能夠更好地使用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的一個要求嗎?如果您只想播放音樂,那麼這會帶來很多開銷。 –