在Soundcloud: Cannot set property 'id' of undefined when trying to play the song被解决后(再次感谢),我将做下一个--我想为按需播放多个歌曲准备多个SM2实例。
下面是代码(这次是用于可读性的非编译CoffeeScript,整个jsbin可以在这里看到http://jsbin.com/ejapin/edit#javascript,html)。
$ ->
SOUNDCLOUD_ID = '6d5064768cc29c71e1f66691f435589a'
PLAYLIST_ID = '1768866'
SC.initialize client_id: SOUNDCLOUD_ID
tracks = []
tracks_total = 0
tracks_ready = ->
for track in tracks
console.log track
track.play()
SC.get '/playlists/' + PLAYLIST_ID, (pl) ->
tracks_total = pl.tracks.length
for track in pl.tracks
console.log "Fetching"
SC.stream "/tracks/#{track.id}", {}, (sound) ->
tracks.push sound
console.log "+ Fetched #{tracks.length}"
if tracks.length == tracks_total
tracks_ready()我看到抓取记录了11次,我也看到SM2的swf被请求了同样的次数。
但是只为(更新的)最后一次曲目调用回调(但声音正在为其播放OK )。
UPD:顺便说一下,它还多次插入SM2 js,这看起来像一个问题。
发布于 2012-05-04 11:14:41
SC JS SDK中有一个错误导致了这种情况。我们今天已经部署了一个修复程序来解决这个问题。谢谢你的报道!如果还有问题,请告诉我。
https://stackoverflow.com/questions/10387993
复制相似问题