SoundCloud + Soundmanager2 + EQData

大城市里の小女人 提交于 2019-12-24 01:01:48

问题


This is essentially the same as this question but with more detail:

Soundcloud + SoundManager bug: reading a stream's eqData

So I have a visualizer using canvas / svg / what have you which looks GREAT when it is receiving EQData from SoundCloud / SoundManager2 but there are some very strange events that are happening which cause it to not be as cool.

1.) When you use SMSound.pause() or any variation (SoundManager.togglePause, etc) and then resume all EQData / WaveformData stops coming to SoundManager2 and it just zeros out.

2.) If you stop a track and restart it, all the EQData / WaveformData stops.

3.) Occasionally and without warning the EQData / WaveformData just stops coming to SM2 and the visualizer just stops, if I go to the next track it starts up again but it never has worked 100% for a song over 30 seconds.

I've not been able to figure out whether this is a SoundCloud or SoundManager2 issue but it seems that some other people have had problems but until now I've been unable to find any solution anywhere.

Link is available here: http://nikru.com/viz/. It is stripped out of the site because it is for a client's unlaunched site which they don't want the public to see yet. :)

Any help is HUGELY appreciated.

Thanks!


回答1:


Okay. I'm sure other people have encountered this and not had a quick fix. I hope this helps someone else as I've been playing with possibilities for a day or so and think I have a workaround for everyone.

What happens is that when SoundManager2 calls the song the first time it requests from the http://api.soundcloud.com/tracks/9708215/stream?consumer_key={YOUR KEY} page. This is great and the song can play just find as api.soundcloud.com has a crossdomain.xml file. What sucks though is that SoundManager2 on the next request (pause / play or next / previous track) just goes back to what it knows (which is a 301'd page at ec-media.soundcloud.com and as I mentioned before ec-media.soundcloud.com has no crossdomain.xml file) this is not great. My fix is every time I start a song over again I modify the Sound's URL to include a new ts={time} argument and then run .load() on the SMSound which causes a reload and fixes the issue.

var $track = $(this),
    data = $track.data('track'),
    playing = $track.is('.active');
newURL  = soundManager.sounds["track_" + data.id].url.split("&ts=")[0];
newURL += "&ts=" + Math.round((new Date()).getTime() / 1000);
soundManager.sounds["track_" + data.id].url = newURL;
soundManager.sounds["track_" + data.id].load();
soundManager.sounds["track_" + data.id].url = newURL;

And then as to save on bandwidth when the song is paused I actually just mute it and save the position the song was paused at. When they unpause I play that track at the position they left off and unmute... It's not pretty but it is the best we can do with what we have (I think).

Hope this helps someone. :)



来源:https://stackoverflow.com/questions/11642556/soundcloud-soundmanager2-eqdata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!