gpt4 book ai didi

html - 如何将 SoundCloud 文件添加到 jPlayer?

转载 作者:搜寻专家 更新时间:2023-10-31 02:26:08 25 4
gpt4 key购买 nike

现在我有一个使用 jPlayer 播放 mp3 的网站。我还希望能够添加让 SoundCloud 直接在播放器上流式传输的功能。

我知道这是可能的,因为我最喜欢的音乐博客之一 hillydilly做这个。通过查看他们的代码,我看到他们的 jPlayer 设置有一些额外的参数,即 sc 和 sclink。

$(".play-music").each(function(){
myPlaylist.add({
title: $(this).attr('data-title'),
artist: $(this).attr('data-artist'),
mp3: $(this).attr('data-mp3'),
url: $(this).attr('data-url'),
sc: $(this).attr('data-sc'),
sclink: $(this).attr('data-sclink')
});
});

我尝试查看他们的其余代码,但无法弄清楚他们如何或在何处实现 sc 和 sclink。有帮助吗?

最佳答案

如果您查看他们的播放列表,他们会链接到 Soundcloud 以获取轨道的 mp3 属性:

myPlaylist.setPlaylist([

{
title:"Close Enough ft. Noosa",
artist:"Ghost Beach",
mp3:"http://api.soundcloud.com/tracks/79031167/stream?client_id=db10c5086fe237d1718f7a5184f33b51",
url:"http://hillydilly.com/2012/12/top-20-songs/",
sc:"true"
},
{
title:"Always",
artist:"Jahan Lennon",
mp3:"http://api.soundcloud.com/tracks/80961874/stream?client_id=db10c5086fe237d1718f7a5184f33b51",
url:"http://hillydilly.com/2012/12/top-20-songs/",
sc:"true"
}

HTML5“流”实际上只是 MP3,您目前无法像使用 Flash、Silverlight、Quicktime 等那样保护它们。如果您直接打开其中一个链接(如 http://api.soundcloud.com/tracks/79031167/stream?client_id=db10c5086fe237d1718f7a5184f33b51),它将下载 MP3。所以我猜你是按照它应该工作的方式来设置它的。

如果您打开 Chrome 及其网络检查器(在开发工具中:查看 > 开发人员 > 开发人员工具,然后单击网络)并单击 Hilly 播放器上的下一步,您可以在后台看到轨道加载。

enter image description here

关于html - 如何将 SoundCloud 文件添加到 jPlayer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15484352/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com