qit*_*tch 9 javascript php soundcloud
所以现在我可以从embed或iframe标签中已经嵌入的soundcloud文件中获取url,并在另一个页面上使用这些url并将其显示在fancybox中.如果用户提供典型的共享网址,http://soundcloud.com/song-b/song-please或者http://snd.sc/yp6VMo?有没有办法在fancybox中获取正确的网址或显示?我试着查看api文档,但我找不到我想要的东西.
Lin*_*n B 18
他试图让html创建一个Soundcloud小部件,而不是获取一个轨道的API网址.该透过oEmbed方法 "将成为任何的SoundCloud URL指向用户,组,设置或播放列表中的小部件嵌入代码",并建议以确保Soundclouds更改不会破坏你的应用程序(而不是使自己的Flash对象或iframe ).您可以使用PHP Web请求来调用它
http://soundcloud.com/oembed?format=js&url=[escaped_url]&iframe=true
Run Code Online (Sandbox Code Playgroud)
或者使用JSON-P调用(为方便起见使用jQuery)
$.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'])
}
)
Run Code Online (Sandbox Code Playgroud)
我正在添加iframe = true所以你得到了新的HTML5播放器,省略了获取旧的Flash对象.它也适用于您正在使用的.sc短网址.
小智 7
你可以尝试这个歌曲网址而不是歌曲网址的id
<iframe width="100%" height="166" scrolling="no" frameborder="no"src="http://w.soundcloud.com/player/?url=http://api.soundcloud.com/elissafranceschi/war&auto_play=false&color=915f33&theme_color=00FF00"></iframe>
Run Code Online (Sandbox Code Playgroud)
我不确定你在这里问什么,但听起来你可能需要"解析"API端点.http://developers.soundcloud.com/docs/api/resolve
例:
$ curl -v 'http://api.soundcloud.com/resolve.json?url=http://soundcloud.com/matas/hobnotropic&client_id=YOUR_CLIENT_ID'
HTTP/1.1 302 Moved Temporarily
Location: http://api.soundcloud.com/tracks/49931.json
Run Code Online (Sandbox Code Playgroud)
这将为您提供所有跟踪信息,这应该足以满足您的任何需要.另外不要忘记HTML5小部件也是如此.