javascript 如何从简单的 soundcloud URL 获取流?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10231333/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 09:08:20  来源:igfitidea点击:

how to get a stream from a simple soundcloud URL?

javascriptsoundcloudsoundmanager2

提问by Fred Guth

I am using Javascript to create yet another custom player for SoundCloud and SoundManager2.

我正在使用 Javascript 为 SoundCloud 和 SoundManager2 创建另一个自定义播放器。

I am able to play a stream from a URI like api.soundcloud.com/tracks/1928712958, but I would like to use a Soundcloud url (like http://soundcloud.com/damianmarley/skrillex-damian-marley-make-it) as the input.

我可以从像 api.soundcloud.com/tracks/1928712958 这样的 URI 播放流,但我想使用 Soundcloud 网址(如http://soundcloud.com/damianmarley/skrillex-damian-marley-make-它)作为输入。

How can I do it?

我该怎么做?

采纳答案by Ahmed Salem

First of all you need to create your own app on sound cloud

首先,您需要在声音云上创建自己的应用程序

After creating app you git

创建应用程序后,你 git

Now you can call soundcloud APIs, but you need to know the userId or PlaylistId or TrackId

现在您可以调用 soundcloud API,但您需要知道 userId 或 PlaylistId 或 TrackId

To know ID of user we can use /resolve function

要知道用户的 ID,我们可以使用 /resolve 函数

Assume user link is

假设用户链接是

https://soundcloud.com/a-salem-2

https://soundcloud.com/a-salem-2

TO know user ID we use resolve function as below

要知道用户 ID,我们使用如下解析功能

http://api.soundcloud.com/resolve.json?url=https://soundcloud.com/a-salem-2&client_id=YOUR_CLIENT_ID

http://api.soundcloud.com/resolve.json?url=https://soundcloud.com/a-salem-2&client_id=YOUR_CLIENT_ID

That will give you userId, In my case it was [75258312]

这会给你 userId,在我的情况下是 [75258312]

To get user tracks

获取用户轨迹

https://api.soundcloud.com/users/75258312/tracks.json?client_id=YOUR_CLIENT_ID

https://api.soundcloud.com/users/75258312/tracks.json?client_id=YOUR_CLIENT_ID

Hope that help :)

希望有所帮助:)