diff --git a/music-web/src/main/webapp/src/app/controller/Main.js b/music-web/src/main/webapp/src/app/controller/Main.js index 9e2f7ab..f1a9e25 100644 --- a/music-web/src/main/webapp/src/app/controller/Main.js +++ b/music-web/src/main/webapp/src/app/controller/Main.js @@ -3,9 +3,22 @@ /** * Main controller. */ -angular.module('music').controller('Main', function($state, $scope, Playlist) { +angular.module('music').controller('Main', function($rootScope, $state, $scope, Playlist) { + $scope.partyMode = Playlist.isPartyMode(); + + // Keep party mode in sync + $rootScope.$on('playlist.party', function(e, partyMode) { + $scope.partyMode = partyMode; + }); + + // Start party mode $scope.startPartyMode = function() { Playlist.party(true, true); $state.transitionTo('main.playing'); }; + + // Stop party mode + $scope.stopPartyMode = function() { + Playlist.setPartyMode(false); + }; }); \ No newline at end of file diff --git a/music-web/src/main/webapp/src/app/controller/Playing.js b/music-web/src/main/webapp/src/app/controller/Playing.js index 6f7deb5..1d3477d 100644 --- a/music-web/src/main/webapp/src/app/controller/Playing.js +++ b/music-web/src/main/webapp/src/app/controller/Playing.js @@ -8,6 +8,7 @@ angular.module('music').controller('Playing', function($scope, Playlist) { $scope.currentOrder = Playlist.currentOrder(); $scope.currentStatus = Playlist.currentStatus(); $scope.tracks = Playlist.getTracks(); + $scope.partyMode = Playlist.isPartyMode(); $scope.duration = _.reduce($scope.tracks, function(duration, track){ return duration + track.length; @@ -22,6 +23,7 @@ angular.module('music').controller('Playing', function($scope, Playlist) { $scope.$on('audio.play', updateScope); $scope.$on('audio.pause', updateScope); $scope.$on('audio.ended', updateScope); + $scope.$on('playlist.party', updateScope); // Remove a track from the playlist $scope.removeTrack = function(order) { diff --git a/music-web/src/main/webapp/src/app/service/Playlist.js b/music-web/src/main/webapp/src/app/service/Playlist.js index 58c75a4..35a6ed0 100644 --- a/music-web/src/main/webapp/src/app/service/Playlist.js +++ b/music-web/src/main/webapp/src/app/service/Playlist.js @@ -43,6 +43,13 @@ angular.module('music').factory('Playlist', function($rootScope, Restangular, to $rootScope.$broadcast('playlist.updated', angular.copy(tracks)); }); + // Fill the playlist with new tracks when in party mode + $rootScope.$on('audio.set', function() { + if (partyMode && currentTrack >= _.size(tracks) - 2) { + service.party(false, false); + } + }); + // Service var service = { /** @@ -324,11 +331,13 @@ angular.module('music').factory('Playlist', function($rootScope, Restangular, to localStorage.playlistVisualization = visualization; }, setPartyMode: function(_partyMode) { + var prev = partyMode; partyMode = _partyMode; - if (partyMode != _partyMode) { + if (partyMode != prev) { $rootScope.$broadcast('playlist.party', partyMode); } - } + }, + isPartyMode: function() { return partyMode; } }; return service; diff --git a/music-web/src/main/webapp/src/partial/main.html b/music-web/src/main/webapp/src/partial/main.html index dbc23b9..6db21f2 100644 --- a/music-web/src/main/webapp/src/partial/main.html +++ b/music-web/src/main/webapp/src/partial/main.html @@ -9,10 +9,14 @@
- + +
diff --git a/music-web/src/main/webapp/src/partial/playing.html b/music-web/src/main/webapp/src/partial/playing.html index d255c20..54434d9 100644 --- a/music-web/src/main/webapp/src/partial/playing.html +++ b/music-web/src/main/webapp/src/partial/playing.html @@ -43,6 +43,9 @@

+ +
+

diff --git a/music-web/src/main/webapp/src/style/main.less b/music-web/src/main/webapp/src/style/main.less index 6715101..d033d68 100644 --- a/music-web/src/main/webapp/src/style/main.less +++ b/music-web/src/main/webapp/src/style/main.less @@ -427,4 +427,12 @@ html, body { width: 100vw; height: 128px; pointer-events: none; +} + +.party-mode-overlay { + position: relative; + background: linear-gradient(rgba(0,0,0,0), rgba(255,255,255,1)); + height: 80px; + top: -90px; + margin-bottom: -80px; } \ No newline at end of file