Soundcloud:准备多个流媒体流?

时间:2012-04-30 17:35:51

标签: javascript soundcloud soundmanager2

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的次数相同。

但回调仅针对(更新的最后曲目进行调用(但声音播放正常)。

UPD:顺便说一下,它还多次插入SM2 js,这看起来像一个问题

1 个答案:

答案 0 :(得分:1)

SC JS SDK中有一个错误导致此问题。 我们今天已经部署了一个修复此问题的修复程序。 谢谢你报道这个!如果仍有问题,请告诉我。