Select Git revision
sso_test.go
player.js 10.02 KiB
// player.js
// Player
djr.Player = function(backend, selector) {
this.backend = backend;
this.playlist = new djr.Playlist();
this.old_songs = [];
this.cur_song = null;
this.auto_extend = true;
// Setup the jPlayer interface.
this.circleplayer = new CirclePlayer(selector, {}, {
supplied: "mp3",
solution: "html,flash",
swfPath: "/static/js",
cssSelectorAncestor: "#cp_container",
error: function(e) {
djr.state.player.reportError(e);
}
});
this.player = this.circleplayer.player;
this.player.bind($.jPlayer.event.ended + '.djr',
function () {djr.state.player.nextSong(); });
};
djr.Player.prototype.hideAllChunks = function() {
$('.chunk .chunk_inner').hide();
};
// Callback for removechunk click.
djr.Player.prototype.removeChunk = function(chunk_id) {
this.playlist.removeChunk(chunk_id);
this.savePlaylist();
$('#chunk_' + chunk_id).remove();
};
// Remove a single song.
djr.Player.prototype.removeSong = function(song) {
$('#song_' + song).remove();
var chunk_to_remove = this.playlist.removeSong(song);
this.savePlaylist();
if (chunk_to_remove > 0) {
$('#chunk_' + chunk_to_remove).remove();
}
};
// Save the current playlist.
djr.Player.prototype.savePlaylist = function() {
this.backend.savePlaylist(this.playlist.uuid, '', this.playlist.allSongs());
};
// Save the current playlist.
djr.Player.prototype.saveNewPlaylist = function(title) {
this.backend.savePlaylist(djr.generateRandomId(), title, this.playlist.allSongs());
};
// Completely clear out the current playlist, and replace it with
// a new empty one.
djr.Player.prototype.clearPlaylist = function() {
this.playlist = new djr.Playlist();
$('#playlistDiv').empty();
};
// Merge all chunks into a single one.
djr.Player.prototype.mergePlaylistChunks = function() {
// Reduce the playlist to a single chunk.
this.playlist = this.playlist.merge();