Skip to content

Commit

Permalink
#27: Party mode playlist interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jendib committed Feb 22, 2015
1 parent 9b5e008 commit 421722b
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 7 deletions.
15 changes: 14 additions & 1 deletion music-web/src/main/webapp/src/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
});
2 changes: 2 additions & 0 deletions music-web/src/main/webapp/src/app/controller/Playing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
13 changes: 11 additions & 2 deletions music-web/src/main/webapp/src/app/service/Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
/**
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 8 additions & 4 deletions music-web/src/main/webapp/src/partial/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
</div>

<div class="panel">
<button class="btn btn-primary btn-block" title="Start listening to your prefered music endlessly" ng-click="startPartyMode()">
<span class="glyphicon glyphicon-glass"></span>
Get the party started!
</button>
<button ng-if="!partyMode" class="btn btn-primary btn-block" title="Start listening to your prefered music endlessly" ng-click="startPartyMode()">
<span class="glyphicon glyphicon-glass"></span>
Get the party started!
</button>
<button ng-if="partyMode" class="btn btn-danger btn-block" ng-click="stopPartyMode()">
<span class="glyphicon glyphicon-stop"></span>
Stop party mode now
</button>
</div>

<div class="panel panel-default">
Expand Down
3 changes: 3 additions & 0 deletions music-web/src/main/webapp/src/partial/playing.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ <h3 class="panel-title">
</tr>
</tbody>
</table>

<div ng-if="partyMode" class="party-mode-overlay">
</div>

<p ng-show="tracks.length == 0" class="text-center">
<span class="glyphicon glyphicon-info-sign"></span>
Expand Down
8 changes: 8 additions & 0 deletions music-web/src/main/webapp/src/style/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 421722b

Please sign in to comment.