var Player = { bar_width: 290, getTrackUrl: function(data) { }, addTrack: function(artist, track, length) { $('.playlist-tracks').append('\
  • \
    \ '+ artist +' — '+ track +'\ '+ length +'\
    \
  • \ '); }, 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() { var artist = $(this).parent().parent().parent().parent().find('.artist-info .name').html(); $(this).parent().parent().find('.tracklist li').each(function(i, item){ var track_name = $(item).find('.trackname').html(); var length = $(item).find('.length').html(); Player.addTrack(artist, track_name, length); }); }) $('.playlist-tracks li').live('dblclick', function(){ Player.setTrack(this); }) $(function(){ Audio.init(); })