2011-06-14 16:05:12 +00:00
|
|
|
var Player = {
|
|
|
|
|
2011-06-14 21:29:36 +00:00
|
|
|
bar_width: 330,
|
2011-06-14 16:05:12 +00:00
|
|
|
|
|
|
|
getTrackUrl: function(data) {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
addTrack: function(artist, track, length) {
|
|
|
|
$('.playlist-tracks').append('\
|
|
|
|
<li id="i'+ Math.round(Math.random() * 999999) +'">\
|
|
|
|
<div class="item">\
|
|
|
|
<span class="title">'+ artist +' — '+ track +'</span>\
|
|
|
|
<span class="duration">'+ length +'</span>\
|
|
|
|
</div>\
|
|
|
|
</li>\
|
|
|
|
');
|
|
|
|
},
|
|
|
|
|
|
|
|
setTrack: function(obj) {
|
|
|
|
var id = $(obj).attr('id');
|
|
|
|
var query = $(obj).find('.title').html();
|
|
|
|
var length = $(obj).find('.duration').html();
|
|
|
|
|
|
|
|
$('#player .now-playing').html(query);
|
|
|
|
$('.playlist-tracks li').removeClass('now');
|
|
|
|
$('#'+ id).addClass('now');
|
|
|
|
|
|
|
|
loadTracksData(query, this.playSource);
|
|
|
|
},
|
|
|
|
|
|
|
|
playSource: function(url) {
|
|
|
|
Audio.setTrack(url);
|
|
|
|
Audio.play();
|
|
|
|
Audio.startListener();
|
|
|
|
},
|
|
|
|
|
|
|
|
updateUI: function(buffered, played) {
|
|
|
|
$('#player .loaded').width(Math.round(buffered * this.bar_width));
|
|
|
|
$('#player .played').width(Math.round(played * this.bar_width));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$('.add-album').live('click', function() {
|
2011-06-14 21:29:36 +00:00
|
|
|
var artist = $('.artist-info .name').html();
|
|
|
|
$(this).parent().parent().parent().find('.tracklist li').each(function(i, item){
|
2011-06-14 16:05:12 +00:00
|
|
|
var track_name = $(item).find('.trackname').html();
|
|
|
|
var length = $(item).find('.length').html();
|
|
|
|
Player.addTrack(artist, track_name, length);
|
|
|
|
});
|
|
|
|
})
|
2011-06-14 21:29:36 +00:00
|
|
|
$('.add-track').live('click', function(){
|
|
|
|
var artist = $('.artist-info .name').html();
|
|
|
|
var track_name = $(this).parent().find('.trackname').html();
|
|
|
|
var length = $(this).parent().find('.length').html();
|
|
|
|
Player.addTrack(artist, track_name, length);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.tracklist li').live('mouseover mouseout', function(e){
|
|
|
|
if (e.type == 'mouseover') {
|
|
|
|
$(this).find('.add-track').show();
|
|
|
|
} else {
|
|
|
|
$(this).find('.add-track').hide();
|
|
|
|
}
|
|
|
|
});
|
2011-06-14 16:05:12 +00:00
|
|
|
|
|
|
|
$('.playlist-tracks li').live('dblclick', function(){
|
|
|
|
Player.setTrack(this);
|
2011-06-14 21:29:36 +00:00
|
|
|
});
|
2011-06-14 16:05:12 +00:00
|
|
|
|
|
|
|
$(function(){
|
|
|
|
Audio.init();
|
2011-06-14 21:29:36 +00:00
|
|
|
});
|