- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在努力弄清楚如何artwork_url
可以从 soundclouds API 使用以便将每个封面输出到 this custom player ,并在播放列表中将每个适当的拇指放在自己的轨道旁边?
我知道我需要使用 artwork_url
属性,但是我不明白这是如何实现的,也不明白如何将其集成到 this particular custom player plugin 中.
特别感谢任何代码示例和/或帮助!
注意:能够通过其他方式控制艺术品的“大小”也很好,然后只是 CSS。
最好的
编辑 #1
我换了 Soundcloud Custom Player on Heroku因为在我能够启动并运行它之后,我发现它的加载时间比我上面引用的原始播放器要快得多(尽管那个播放器仍然非常棒)......
但是,我现在仍然像以前一样执行相同的任务 - 如何将专辑封面添加到脚本并相应地输出?
下面粘贴的是Heroku球员:
// # SoundCloud Custom Player
// Make sure to require [SoundManager2](http://www.schillmania.com/projects/soundmanager2/) before this file on your page.
// And set the defaults for it first:
soundManager.url = 'http://localhost:8888/wp-content/themes/earpeacerecords/swf';
soundManager.flashVersion = 9;
soundManager.useFlashBlock = false;
soundManager.useHighPerformance = true;
soundManager.wmode = 'transparent';
soundManager.useFastPolling = true;
// Wait for jQuery to load properly
$(function(){
// Wait for SoundManager2 to load properly
soundManager.onready(function() {
// ## SoundCloud
// Pass a consumer key, which can be created [here](http://soundcloud.com/you/apps), and your playlist url.
// If your playlist is private, make sure your url includes the secret token you were given.
var consumer_key = "915908f3466530d0f70ca198eac4288f",
url = "http://soundcloud.com/poe-epr/sets/eprtistmix1";
// Resolve the given url and get the full JSON-worth of data from SoundCloud regarding the playlist and the tracks within.
$.getJSON('http://api.soundcloud.com/resolve?url=' + url + '&format=json&consumer_key=' + consumer_key + '&callback=?', function(playlist){
// I like to fill out the player by passing some of the data from the first track.
// In this case, you'll just want to pass the first track's title.
$('.title').text(playlist.tracks[0].title);
// Loop through each of the tracks
$.each(playlist.tracks, function(index, track) {
// Create a list item for each track and associate the track *data* with it.
$('<li>' + track.title + '</li>').data('track', track).appendTo('.tracks');
// * Get appropriate stream url depending on whether the playlist is private or public.
// * If the track includes a *secret_token* add a '&' to the url, else add a '?'.
// * Finally, append the consumer key and you'll have a working stream url.
url = track.stream_url;
(url.indexOf("secret_token") == -1) ? url = url + '?' : url = url + '&';
url = url + 'consumer_key=' + consumer_key;
// ## SoundManager2
// **Create the sound using SoundManager2**
soundManager.createSound({
// Give the sound an id and the SoundCloud stream url we created above.
id: 'track_' + track.id,
url: url,
// On play & resume add a *playing* class to the main player div.
// This will be used in the stylesheet to hide/show the play/pause buttons depending on state.
onplay: function() {
$('.player').addClass('playing');
$('.title').text(track.title);
},
onresume: function() {
$('.player').addClass('playing');
},
// On pause, remove the *playing* class from the main player div.
onpause: function() {
$('.player').removeClass('playing');
},
// When a track finished, call the Next Track function. (Declared at the bottom of this file).
onfinish: function() {
nextTrack();
}
});
});
});
// ## GUI Actions
// Bind a click event to each list item we created above.
$('.tracks li').live('click', function(){
// Create a track variable, grab the data from it, and find out if it's already playing *(set to active)*
var $track = $(this),
data = $track.data('track'),
playing = $track.is('.active');
if (playing) {
// If it is playing: pause it.
soundManager.pause('track_' + data.id);
} else {
// If it's not playing: stop all other sounds that might be playing and play the clicked sound.
if ($track.siblings('li').hasClass('active')) { soundManager.stopAll(); }
soundManager.play('track_' + data.id);
}
// Finally, toggle the *active* state of the clicked li and remove *active* from and other tracks.
$track.toggleClass('active').siblings('li').removeClass('active');
});
// Bind a click event to the play / pause button.
$('.play, .pause').live('click', function(){
if ( $('li').hasClass('active') == true ) {
// If a track is active, play or pause it depending on current state.
soundManager.togglePause( 'track_' + $('li.active').data('track').id );
} else {
// If no tracks are active, just play the first one.
$('li:first').click();
}
});
// Bind a click event to the next button, calling the Next Track function.
$('.next').live('click', function(){
nextTrack();
});
// Bind a click event to the previous button, calling the Previous Track function.
$('.prev').live('click', function(){
prevTrack();
});
// ## Player Functions
// **Next Track**
var nextTrack = function(){
// Stop all sounds
soundManager.stopAll();
// Click the next list item after the current active one.
// If it does not exist *(there is no next track)*, click the first list item.
if ( $('li.active').next().click().length == 0 ) {
$('.tracks li:first').click();
}
}
// **Previous Track**
var prevTrack = function(){
// Stop all sounds
soundManager.stopAll();
// Click the previous list item after the current active one.
// If it does not exist *(there is no previous track)*, click the last list item.
if ( $('li.active').prev().click().length == 0 ) {
$('.tracks li:last').click();
}
}
});
});
$.getJSON('http://api.soundcloud.com/resolve?url=' + url + '&format=json&consumer_key=' + consumer_key + '&callback=?', function(playlist){
// I like to fill out the player by passing some of the data from the first track.
// In this case, you'll just want to pass the first track's title.
$('.title').text(playlist.tracks[0].title);
$('.album_art').attr('src', playlist.artwork_url);
// Loop through each of the tracks
$.each(playlist.tracks, function(index, track) {
// Create a list item for each track and associate the track *data* with it.
$('<li>' + '<img src="' + playlist.artwork_url + '">' + track.title + '</li>').data('track', track).appendTo('.tracks');
// * Get appropriate stream url depending on whether the playlist is private or public.
// * If the track includes a *secret_token* add a '&' to the url, else add a '?'.
// * Finally, append the consumer key and you'll have a working stream url.
url = track.stream_url;
(url.indexOf("secret_token") == -1) ? url = url + '?' : url = url + '&';
url = url + 'consumer_key=' + consumer_key;
// ## SoundManager2
// **Create the sound using SoundManager2**
soundManager.createSound({
// Give the sound an id and the SoundCloud stream url we created above.
id: 'track_' + track.id,
url: url,
// On play & resume add a *playing* class to the main player div.
// This will be used in the stylesheet to hide/show the play/pause buttons depending on state.
onplay: function() {
$('.player').addClass('playing');
$('.title').text(track.title);
},
onresume: function() {
$('.player').addClass('playing');
},
// On pause, remove the *playing* class from the main player div.
onpause: function() {
$('.player').removeClass('playing');
},
// When a track finished, call the Next Track function. (Declared at the bottom of this file).
onfinish: function() {
nextTrack();
}
});
});
<div class='title'></div>
<a class='prev'>Previous</a>
<a class='play'>Play</a>
<a class='pause'>Pause</a>
<a class='next'>Next</a>
</div>
/*
-------------------------------------------------------------------------
Soundcloud Player
-------------------------------------------------------------------------
*/
#sticky_header #sticky_content .player {
height: 570px;
overflow: hidden;
}
#sticky_header #sticky_content .tracks {
}
#sticky_header #sticky_content .tracks li {
cursor: pointer;
height: 40px;
text-align: left;
}
#sticky_header #sticky_content .tracks li img.album_art {
width: 40px;
height: 40px;
border-radius: 5px;
margin-right: 15px;
}
#sticky_header #sticky_content .title {
}
#sticky_header #sticky_content .prev {
}
#sticky_header #sticky_content .play {
display: block;
}
#sticky_header #sticky_content .playing .play {
display: none;
}
#sticky_header #sticky_content .pause {
display: none;
}
#sticky_header #sticky_content .playing .pause {
display: block;
}
#sticky_header #sticky_content .next {}
最佳答案
要获取图像,您可以使用以下代码:
//get element by id from your iframe
var widget = SC.Widget(document.getElementById('soundcloud_widget'));
widget.getCurrentSound(function(music){
artwork_url = music.artwork_url.replace('-large', '-t200x200');
$('#song1').css('background', 'url(\"'+artwork_url+'\") ');
});
关于soundcloud - 从 Soundcloud API 获取artwork_url 并在自定义 SC/SM2 播放器中显示专辑封面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15624181/
我是 Spark 的新手。有人可以清除我的疑问吗: 让我们假设下面是我的代码: a = sc.textFile(filename) b = a.filter(lambda x: len(x)>0 an
问题 每行输入都将包含一个字符串,后跟一个整数。每个字符串最多包含 10 个字母字符,每个整数都在 0 到 999 的范围内 输出代码 在输出的每一行中应该有两列:第一列包含字符串,并使用 15 个字
我希望从不同供应商、不同用途、不同 APDU 的一堆智能卡中读取一些基本信息。例如:国家身份识别智能卡、EMV(支付)、手机SIM、javacard等... 我编写了一个 Java 应用程序。让我将
我有一组我想读入 RDD 的日志文件。 这些日志文件都是压缩的 gzip 文件,文件名是 日期盖章。 我一直在用sc.wholeTextFiles()读入文件,似乎我遇到了 Java 堆内存问题。为了
我使用以下命令创建服务:sc create MyService binpath= "C:\Path\MyDriver.sys" 返回的消息是:[SC] CreateService SUCCESS,但是
我使用 Spring mvc,我的问题是关于 sendError方法来自 HttpServletResponse . 有人可以告诉我哪个最好: @RequestMapping(method = Req
class superClass {} class subClass extends superClass{} public class test { public static void m
我在ConcurrentHashMap中阅读了addCount函数的源代码, 但我不知道什么时候可以实现( sc == rs + 1 || sc == rs + MAX_RESIZERS)条件。 为什
我正在尝试使用 Sproutcore 呈现 UI,其中我有一个列表列表。有一个垂直的数据列表,其中每个关联的项目都有自己的项目列表。我已经根据我对 Sproutcore 的了解设置了我认为合适的模型。
当我通过 http://software.intel.com/en-us/android 安装 Intelhaxm 时并且我成功安装了,但是当我尝试使用管理员在命令提示符下验证 Intelhaxm 是
我试图在我的 MVC - Sitecore - 7.1 中的 v4.0.30319 项目中使用 Glass Mapper。 以下是我安装的 Glass Mapper 版本 Glass Mapper 版
在我通过取消注释文件中的以下行来更改 svnserve.conf 之后,我正在尝试使用 cmd 创建一个 svnserver, anon-access = read auth-access = wri
有没有办法让 java 使用 javax.smartcardio.TerminalFactory 识别我的 NFC 读卡器? 我正在使用 Ubuntu 13.04 并使用 pcsc_scan 我能够读
我正在使用 sc.exe 命令来安装 C# windows 服务。 C:Windows\System32> sc.exe Create "TestService1" binPath= "C:\Prog
sc-bytes 代表什么?每一个关于 sc-bytes 的讨论和博客都声明它代表从服务器到客户端的字节。 想知道sc-bytes是否代表总响应字节数, 例如,。当我们访问任何 URL 时,它是否包含
topLeftView: SC.ScrollView.design({ backgroundColor: "#DADFE6", childViews: 'labLabel labMem
我想将一些已解析的 JSON 数据从我的 Controller 推送到 SC.SourceListView (Sproutcore Showcase) .我使用 SC.TreeController并将
您对此有什么解决方案吗? 我想得到 SC.SceneView从下到上过渡,而不是从左到右或从右到左。 Doc在这里并没有说太多,但是由于原始转换必须在某个地方,也许我可以为此创建其方法的原型(prot
我正在基于SproutCore 1.8的项目中。我的应用程序必须在复杂的表格 View 中显示大量数据。实际上,表格 View 将成为应用程序界面的核心元素之一。另外,我可能需要大纲/树 View ,
我正在尝试在SproutCore应用程序中按部门显示联系人列表,并尝试将SC.ListView嵌套在另一个SC.ListView中无济于事。 我可以use SC.GridView to assist,
我是一名优秀的程序员,十分优秀!