如何使用SoundManager2从SoundCloud流,并进行可视化? [英] How to use SoundManager2 to stream from SoundCloud, and make visualizations?

查看:139
本文介绍了如何使用SoundManager2从SoundCloud流,并进行可视化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SoundManager2得到一个数据的错误,我不能想象什么?

SoundManager2 gets a data error and I cannot visualize anything?

我无法访问歌曲,权限被拒绝?

I cannot access the song, permission denied?

它的工作原理,当我第一次玩,但如果我暂停和重新播放,我得到一个数据错误?

It works when I first play it, but if I pause it and play again, I get a data error?

推荐答案

本最近被固定的,因为这部分是由于所需的文件在那里的一半。现在,它是固定的但是,它仍然可能无法正常工作了蝙蝠。

This has recently been fixed, as it was partly due to half of the needed files being there. Now it is fixed however, it still might not work off the bat.

最明显的第一步是使用API​​来获取赛道stream_url,它看起来像 http://api.soundcloud.com/tracks/69322564/stream?client_id=CLIENT_ID

The obvious first step is you use the api to get the track stream_url, which looks like http://api.soundcloud.com/tracks/69322564/stream?client_id=CLIENT_ID

如果您使用本作中的SoundCloud媒体的网址,你会发现你preSS发挥,如果你有可视化效果,他们将工作,一切是好的。但是,如果你现在暂停曲目,和preSS再次播放,你会得到一个错误的数据,元数据将不再是访问,和你的可视化将打破。这是因为 api.soundcloud.com 有一个跨域文件,当你访问它,你得到一个3XX重定向到 ec-media.soundcloud.com 。这个网站现在也有一个crossdomain.xml文件,但是那个讨厌的3XX重定向废墟既权限,所以你打一个错误。

If you use this as the media url in SoundCloud, you will find that you press play, and if you have visualizations they will work, and everything is nice. However if you now pause the track, and press play again, you will get a data error, metadata will cease to be accessible, and your visualizations will break. This is because api.soundcloud.com has a crossdomain file, and when you access it you get a 3XX redirect to ec-media.soundcloud.com. This site now also has a crossdomain.xml file, however that pesky 3XX redirect ruins both permissions, so you hit an error.

这个问题的答案是您重定向飞跃第一,soundmanager2外面,所以没有重定向,这将打破它。例如在Python:

The answer to this is you make the redirect leap first, outside of soundmanager2, so that there is no redirect that will break it. For instance in Python:

import urllib2
starturl = 'http://api.soundcloud.com/tracks/69322564/stream?client_id=CLIENT_ID'
res = urllib2.urlopen(starturl)
finalurl = res.geturl()
print finalurl

这可能是更优雅,但它会打印该API重定向的URL。该网址看起来像<$c$c>http://ec-media.soundcloud.com/2j0lNF81jv9m.128.mp3?LONG_STRING&AWSAccessKeyId=ACCESS_KEY&Expires=1355864871&Signature=SIGNATURE

This could be more elegant, but it will print the url that the api redirects to. This url will look something like http://ec-media.soundcloud.com/2j0lNF81jv9m.128.mp3?LONG_STRING&AWSAccessKeyId=ACCESS_KEY&Expires=1355864871&Signature=SIGNATURE

该域具有crossdomain.xml文件,并且由于这样的事实,有没有重定向,事情会平稳运行,数据将被访问的,一切都会好起来。

This domain has the crossdomain.xml file, and due to the fact that there is no redirect, things will run smoothly, data will be accessed, all will be well.

我这样做,它的工作,但现在它说,该文件禁止

"I did this and it worked, but now it says the file is forbidden"

现在,我们提请您注意previous网址,特别是&安培;过期= 1355864871 。你会被重定向到该文件不是永久性的,所以你需要每次都抓住它。对我来说这是很容易的,我在Django工作,所以我可以在我的看法脚本只需运行上面的蟒蛇。你必须找到一种方法,在你选择的code来实现这一点。 (应该在JavaScript工作太)。

Now we draw your attention to the previous url, in particular &Expires=1355864871. The file you are redirected to is not permanent, so you need to grab it each time. For me this is easy, I work in django so I can simply run the python above in my views scripts. You'll have to find a way to implement this in your code of choice. (Should work in javascript too).

在这一切都完成后,你应该能够暂停和播放,只要你想尽可能多的和检索的波形数据,情商数据,以及峰值数据。有了这些东西,一些有趣的事情可以做。希望这有助于。

After all this is done, you should be able to pause and play as much as you want, and retrieve the waveform data, the EQ data, and the peak data. With these things, some fun things can be done. Hope this helped.

这篇关于如何使用SoundManager2从SoundCloud流,并进行可视化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆