2013-07-10 44 views
1

我在一个项目中使用的Java脚本的SoundCloud SDK(http://developers.soundcloud.com/docs/api/sdks#javascript),并愉快地得到了我的播放器加载声音和演奏它像这样SoundManager类事件:的SoundCloud SC.Stream无法访问

SC.get("/resolve/",{ 
    url: href 
},function(response){    
    SC.stream("/tracks/"+response.id,{},function(sound){ 
     sound.play(); 

    }); 
}) 

我可以触发声音管理对象使用sound.play()在回调中播放,但我不能解决如何访问文档中提到的对象的事件(http://www.schillmania.com/projects/soundmanager2/doc/)like whileplay()

如何添加这些在?我试过这种东西:

sound.whileplaying(function(){ 
    alert("hooray!") 
}) 

但这并不奏效。

非常感谢 朱利安

回答

3

这应该工作:

SC.stream("/tracks/" + response.id, { 
    whileplaying: function() { 
    console.log("track is playing"); 
    } 
}, function (sound) { 
    sound.play(); 
}); 
0

正确的方法是:

SC.stream('/tracks/' + response.id).then(function (player) { 
    player.on('finish', function() { 
     console.log('finish'); 
    }); 
    player.play(); 
}); 

你找到这个答案,在这里咨询的所有事件: https://developers.soundcloud.com/docs/api/sdks#player