实现soundcloud播放器

时间:2013-05-29 07:09:14

标签: php javascript soundcloud

是否可以在我存储在我的数据库中的文本中找到链接,这些链接以www.soundcloud.com或http://soundcloud.com开头,确定是否引用带有歌曲的页面(对于示例soundcloud用户配置文件)如果是,则显示soundcloud播放器而不是链接,就像在facebook上完成的那样...?

1 个答案:

答案 0 :(得分:2)

是的,有可能。

您可以使用以下网址查询oembed服务:

http://soundcloud.com/oembed.json?url=http://soundcloud.com/crystalfighters

然后它将返回JSON,其中小部件的HTML表示为html属性

{
version: 1,
type: "rich",
provider_name: "SoundCloud",
provider_url: "http://soundcloud.com",
height: 450,
width: "100%",
title: "Crystal Fighters",
description: "http://facebook.com/crystalfighters BUY NEW ALBUM 'CAVE RAVE' NOW: hhttp://po.st/caveravebuy LIVE+DJ Bookings ex-US GregLowe@theagencygroup.com US bookings carter@windishagency.com Management info@giantmenmanagement.com",
thumbnail_url: "http://i1.sndcdn.com/avatars-000041667144-lcvdi5-t500x500.jpg?9d68d37",
html: "<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fusers%2F114019&show_artwork=true"></iframe>",
author_name: "Crystal Fighters",
author_url: "http://soundcloud.com/crystalfighters"
}

或将返回HTTP 404,这意味着此URL不是有效的或公共的SoundCloud资源