Adds back scrobbling and loading a track and the queue from localStorage.
- Splits loadTrackPosition into two functions : one for the track (which isn't finished), one for the queue. - Adds main-controller.js' first unit tests for both these functions. - Adds scrobbling functionnality. It is now a part of the Subsonic service, since we it's Subsonic that ultimately does the scroblling. - Adds unit tests for both the service and the directive. The test for updatetime was crazy hard to do because I had to find a way to trigger my own fake event and it wasn't permitted by jplayer. - Adds the load function to the player, it is used only when loading a song from localStorage. - Removes ng-click from play/pause in the player template. jPlayer adds its own handlers on them, no need to do it twice.
This commit is contained in:
parent
59762ae423
commit
834e67946c
10 changed files with 447 additions and 187 deletions
|
@ -443,27 +443,33 @@
|
|||
return $sce.trustAsHtml(html);
|
||||
};
|
||||
|
||||
function loadTrackPosition() {
|
||||
//TODO: HYZ: Unit test
|
||||
$scope.loadTrackPosition = function () {
|
||||
if (utils.browserStorageCheck()) {
|
||||
// Load Saved Song
|
||||
var song = angular.fromJson(localStorage.getItem('CurrentSong'));
|
||||
if (song) {
|
||||
player.load(song);
|
||||
// Load Saved Queue
|
||||
var items = angular.fromJson(localStorage.getItem('CurrentQueue'));
|
||||
if (items) {
|
||||
player.queue = items;
|
||||
if (player.queue.length > 0) {
|
||||
notifications.updateMessage(player.queue.length + ' Saved Song(s)', true);
|
||||
}
|
||||
if (globals.settings.Debug) { console.log('Play Queue Loaded From localStorage: ' + player.queue.length + ' song(s)'); }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (globals.settings.Debug) { console.log('HTML5::loadStorage not supported on your browser'); }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.loadQueue = function () {
|
||||
if(utils.browserStorageCheck()) {
|
||||
// load Saved queue
|
||||
var queue = angular.fromJson(localStorage.getItem('CurrentQueue'));
|
||||
if (queue) {
|
||||
player.queue = queue;
|
||||
if (player.queue.length > 0) {
|
||||
notifications.updateMessage(player.queue.length + ' Saved Song(s)', true);
|
||||
}
|
||||
if (globals.settings.Debug) { console.log('Play Queue Loaded From localStorage: ' + player.queue.length + ' song(s)'); }
|
||||
}
|
||||
} else {
|
||||
if (globals.settings.Debug) { console.log('HTML5::loadStorage not supported on your browser'); }
|
||||
}
|
||||
};
|
||||
|
||||
/* Launch on Startup */
|
||||
$scope.loadSettings();
|
||||
|
@ -476,7 +482,8 @@
|
|||
if ($scope.loggedIn()) {
|
||||
//$scope.ping();
|
||||
if (globals.settings.SaveTrackPosition) {
|
||||
loadTrackPosition();
|
||||
$scope.loadQueue();
|
||||
$scope.loadTrackPosition();
|
||||
//FIXME: HYZ: player.startSaveTrackPosition();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue