我正在为客户创建一个音乐网站,但是当我尝试将音乐播放器整合到主网站时,播放器会中断,我会收到此错误
soundManager.createSound():undefined
我已经尝试了所有javascript文件的变种并将所有内容删除,以确保它不会冲突文件。有时它有效,有时,所以我猜它可能是加载的问题。 由于文件太多而无法分解,我将链接到网站中单独播放器和播放器的开发版本,希望有人知道发生了什么。
fullwebsites音乐播放器位于音乐标签上。在两个版本上启动播放器,单击中间的方块,音乐应该在之后自动开始。
包括/ Javascript角/ application.js中
$(document).ready(function() {
var client_id = "bcc776e7aa65dbc29c40ff21a1a94ecd",
page_title = document.title,
user = 'skibsthekid',
messageTimer = 0,
lock = false;
soundManager.url = "includes/swfs/";
soundManager.flashVersion = 9;
//Get playlists from account
$.getJSON('http://api.soundcloud.com/users/'+ user +'/playlists.json?client_id=' + client_id, { get_param: 'value' }, function(data_playlists) {
$.each(data_playlists, function(index, playlists) {
//Get playlists data
i = 1;
$.getJSON(playlists.uri + '.json?client_id=' + client_id, { get_param: 'value' }, function(playlist) {
$("<div class='player' id='id" + i +"'><div class='panel right'><div class='avatar'><img></div><div class='description'></div><ol class='tracks'></ol></div><div class='panel left'><div class='artwork'><img /><div class='button'><div class='play'></div></div></div></div></div>").prependTo('.soundcloud');
//get track data
$.each(playlist.tracks, function(index, track) {
// Create a list item for track, associate it's data, and append it to the track list.
var $li = $('<li class="track_' + track.id + '">' + (index + 1) + '. ' + track.title + '</li>').data('track', track).appendTo('#id'+i+' .tracks');
// Find the appropriate stream url depending on whether the track has a secret_token or is public.
url = track.stream_url;
(url.indexOf("secret_token") == -1) ? url = url + '?' : url = url + '&';
url = url + 'client_id=' + client_id;
var s = soundManager.createSound({
// ### Sound Defaults
// * Auto load the first track
autoLoad: (index == 0),
id: 'track_' + track.id,
multiShot: false,
url: url,
volume: 100,
// ### Sound Functions
// **On Play** swap the waveform image, change the page title, and adjust the buffer if it's fully loaded.
onplay: function() {
document.title = '\u25B6 ' + track.title;
},
// **On Resume** change the page title, and adjust the buffer if it's full loaded.
onresume: function() {
document.title = '\u25B6 ' + track.title;
},
// **On Stop** revert the page title to default and set buffer and played's width to 0
onstop: function() {
document.title = page_title;
$('.message').hide();
},
// **On Pause** revert the page title
onpause: function() {
document.title = page_title;
},
// **On Finish** jump to the next track
onfinish: function() {
nextTrack();
}
});
// Load first track
if (index == 0) {
// Make the first track active because it has been loaded automagically
$li.addClass('active').addClass('preloaded');
}
});
if (playlist.artwork_url) {
$('#id'+i).find('.artwork img').attr('src', playlist.artwork_url.replace('-large', '-crop'));
} else {
$('#id'+i).find('.artwork img').attr('src', "http://i1.sndcdn.com/artworks-000017199115-fganhh-crop.jpg?6425e9e");
}
$('.artwork').fadeIn('slow');
$('#id'+i).find('.avatar img').attr('src', playlist.user.avatar_url.replace('-large', '-badge'));
$('#id'+i).find('.avatar').css('background-image', 'url(' + playlist.user.avatar_url.replace('-large', '-badge') + ')');
$('#id'+i).find('.description').html(playlist.title + '<br>by ' + playlist.user.username);
i++
});
});
});
// Bind a *click* event to each list item in the track list
$('.tracks li').live('click', function() {
// Create variables for the track, its data, and whether or not it's playing
var $track = $(this),
data = $track.data('track'),
playing = $track.is('.playing');
// If is it playing, pause it.
if (playing) {
soundManager.pause('track_' + data.id);
// If not, stop all other sounds that might be playing, and play the clicked sound.
} else {
if ($track.siblings('li').hasClass('playing')) {
soundManager.stopAll();
}
$track.addClass('active').siblings('li').removeClass('active');
soundManager.play('track_' + data.id);
}
// Toggle the playing class and remove it from any other list items.
$track.toggleClass('playing').siblings('li').removeClass('playing');
});
// ### Play Button Click
// Bind a *click* event to the play button
$('.button').live('click', function() {
// Fade out the play button
$(this).fadeOut();
var id = $(this).parents('.player').attr('id');
// Unlock the player
unlockPlayer(id);
});
// Unlock Player
var unlockPlayer = function(id) {
// Click/Play the first track
$('#'+id).find('li.active').click();
// Declare basic animation variables
var duration = 4000,
easing = 'swing';
// Animate the left & right panels to swing open
$('#'+id).find('.left').animate({
left: 0,
BorderTopRightRadius: 0,
BorderBottomRightRadius: 0,
WebkitBorderTopRightRadius: 0,
WebkitBorderBottomRightRadius: 0,
MozBorderRadiusTopright: 0,
MozBorderRadiusBottomright: 0
}, {
duration: duration,
easing: easing
});
$('#'+id).find('.right').animate({
left: $('.player').width() / 2,
BorderTopLeftRadius: 0,
BorderBottomLeftRadius: 0,
WebkitBorderTopLeftRadius: 0,
WebkitBorderBottomLeftRadius: 0,
MozBorderRadiusTopleft: 0,
MozBorderRadiusBottomleft: 0
}, {
duration: duration,
easing: easing
});
}
// Loads the next track or first if there isn't a next track
var nextTrack = function() {
soundManager.stopAll();
if ($('li.active').next().click().length == 0) {
$('.tracks li:first').click();
}
}
});