2013-02-13 25 views
0

我在使用SoundCloud getter getCurrentSound(回調)時遇到問題。我試圖將當前存儲在小部件中的歌曲作爲var存儲,因此我可以將它作爲參數傳遞給我的一個ruby方法。使用SoundCloud Getters

我曾嘗試以下,它不工作:

var current song = SC.Widget("sc-widget").getCurrentSound() 

以下是有關的SoundCloud使用干將信息: 如果http://developers.soundcloud.com/docs/api/html5-widget

+0

你在用什麼語言,是否有任何代碼片段可以發佈,以便我們可以看到一些上下文? – Walls 2013-02-13 20:27:06

+0

是否提供編輯幫助? – bsiddiqui 2013-02-13 21:20:35

+0

您發佈的代碼的一個明顯問題是'var current song'不是有效的變量名稱...... – nickf 2013-02-17 20:50:49

回答

2

對不起文檔不明確這一點。 getCurrentSound()方法是異步的,所以它不會返回值,而是需要回調。試試這個:

var widget = SC.Widget(...); 
widget.getCurrentSound(function(sound) { 
    console.log(sound.title); 
}); 

希望有幫助。讓我知道如果它仍然不清楚。