我正在尝试通过单击链接时加载SoundCloud小部件来加快工作的网站的速度,而且还可以根据需要设置SoundCloud小部件的样式,即:
http://www.instrumentalbackgroundmusic.com/royalty-free-music/happy-go-lucky/
但是,我无法正确显示某些东西,例如小部件的颜色和类型(即带有波形和图形表达)。
我在这里查看了SoundCloud文档,并提出了以下建议:
JS小提琴: http : //jsfiddle.net/3nj7qrpz/1/
$(document).ready(function() {
// Load iFrame on click
$('.scload').click(function(){
event.preventDefault();
var formatPlayer = '&iframe=true';
formatPlayer += '&color=0080ca'; // This doesn't do anything
formatPlayer += '&visual=false'; // This doesn't do anything
formatPlayer += '&auto_play=true'; // Play on load
formatPlayer += '&buying=false';
formatPlayer += '&download=true';
formatPlayer += '&show_playcount=true'; // This doesn't work
formatPlayer += '&show_reposts=false';
formatPlayer += '&show_artwork=true';
formatPlayer += '&show_user=false';
formatPlayer += '&show_comments=false';
formatPlayer += '&liking=true';
formatPlayer += '&hide_related=true';
formatPlayer += '&sharing=false';
formatPlayer += '&maxheight=166';
var $link = $(this);
var getJSONstring = 'http://soundcloud.com/oembed?format=js&url=' + $link.attr('href') + formatPlayer;
// Replace contents
$.getJSON(getJSONstring + '&callback=?', function(response) {
$link.replaceWith(response.html);
});
});
});
似乎某些电话无法正常工作。谁能看到问题所在?我添加了哪些呼叫似乎在我的评论中不起作用。
谢谢
大须
好的,我找到了一种将小部件类型更改为所需样式的方法。这是与之有关的,?visual=true
所以我将其更改为?visual=false
通过jQuery。如果有更好的方法,请告诉我!
JS小提琴: http ://jsfiddle.net/3nj7qrpz/2/
$(document).ready(function() {
// Load iFrame on click
$('.scload').click(function(){
event.preventDefault();
var formatPlayer = '&iframe=true';
formatPlayer += '&color=0080ca';
formatPlayer += '&auto_play=true'; // Play once user clicks link!
formatPlayer += '&buying=false';
formatPlayer += '&download=true';
formatPlayer += '&show_playcount=false';
formatPlayer += '&show_reposts=false';
formatPlayer += '&show_artwork=true';
formatPlayer += '&show_user=false';
formatPlayer += '&show_comments=false';
formatPlayer += '&liking=false';
formatPlayer += '&hide_related=true';
formatPlayer += '&sharing=false';
formatPlayer += '&maxheight=166';
var $link = $(this);
var getJSONstring = 'http://soundcloud.com/oembed?format=js&url=' + $link.attr('href') + formatPlayer;
// Replace contents
$.getJSON(getJSONstring + '&callback=?', function(response) {
var widget = response.html;
var src = $(widget).attr('src');
widget = $(widget).attr('src', src.replace('?visual=true', '?visual=false')); // Update iFrame src
$link.replaceWith(widget);
});
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句