如何从标准网址获取适当的soundcloud网址? [英] How to get proper soundcloud url for embedding from a standard url?

查看:102
本文介绍了如何从标准网址获取适当的soundcloud网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以现在我可以从embed或iframe标签中已嵌入的soundcloud文件中获取网址,并在其他网页上使用这些网址并将其显示在fancybox中。如果用户提供典型的共享网址,例如 http://soundcloud.com/song-b/song-please 或 http://snd.sc/yp6VMo ?我试着查看api文档,但我找不到我想要的东西。

So right now I can grab the url from already embedded soundcloud files in embed or iframe tags and use those urls on another page and display it in fancybox. Is there a way to get the right url or display in fancybox if a user offers a typical share url such as http://soundcloud.com/song-b/song-please or http://snd.sc/yp6VMo? I tried looking at the api documentation but I couldn't really find what I was looking for.

推荐答案

他正试图搞定用于创建Soundcloud小部件的html,而不是获取轨道的API网址。 oEmbed方法将为指向用户,组的任何SoundCloud URL提供小部件嵌入代码,设置或播放列表并建议确保Soundclouds更改不会破坏您的应用程序(而不是制作您自己的Flash对象或iframe)。您可以通过PHP Web请求调用它

He is trying to get html to create a Soundcloud widget, not get the API url for a track. The oEmbed method "will serve the widget embed code for any SoundCloud URL pointing to a user, group, set or a playlist" and is recommended to make sure Soundclouds changes don't break your app (as opposed making your own Flash object or iframe). You can call it with a PHP web request to

http://soundcloud.com/oembed?format=js&url=[escaped_url]&iframe=true

或者使用JSON-P调用(为方便起见使用jQuery)

Or with a JSON-P call (using jQuery for convenience)

$.getJSON('http://soundcloud.com/oembed?callback=?',
    {format: 'js', url: 'http://snd.sc/yp6VMo', iframe: true},
    function(data) {
        // Stick the html content returned in the object into the page
        $('#your_player_div').html(data['html'])
    }
)

我正在添加iframe = true所以你得到了新的HTML5播放器,省略了获取旧的Flash对象。它也适用于您正在使用的.sc短网址。

I'm adding iframe=true so you get the new HTML5 player, omit to get the old Flash object. It also works with the .sc short urls you are using.

这篇关于如何从标准网址获取适当的soundcloud网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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