Adds back displaying the currently playing song as such in the queue
We no longer alter the song, the queue gets this from the player. That way we can't have two songs marked as 'playing' at the same time.
This commit is contained in:
parent
c787c468b9
commit
3c809d1903
7 changed files with 31 additions and 47 deletions
|
@ -103,6 +103,7 @@ angular.module('JamStash')
|
|||
};
|
||||
|
||||
$scope.$watchCollection('queue', function(newItem, oldItem) {
|
||||
// TODO: Hyz: Replace
|
||||
if (oldItem.length != newItem.length
|
||||
&& globals.settings.ShowQueue) {
|
||||
$rootScope.showQueue();
|
||||
|
@ -123,14 +124,7 @@ angular.module('JamStash')
|
|||
$('#right-component').addClass('lgcolumn_expanded');
|
||||
};
|
||||
$scope.toggleQueue = function () {
|
||||
if ($('#SideBar').css('display') == 'none') {
|
||||
$rootScope.showQueue();
|
||||
} else {
|
||||
$rootScope.hideQueue();
|
||||
}
|
||||
};
|
||||
$scope.toggleQueue = function () {
|
||||
if ($('#SideBar').css('display') == 'none') {
|
||||
if ($('#SideBar').css('display') === 'none') {
|
||||
$rootScope.showQueue();
|
||||
} else {
|
||||
$rootScope.hideQueue();
|
||||
|
@ -275,6 +269,7 @@ angular.module('JamStash')
|
|||
});
|
||||
};
|
||||
$rootScope.playAll = function (songs) {
|
||||
// TODO: Hyz: Replace
|
||||
$rootScope.queue = [];
|
||||
$rootScope.selectAll(songs);
|
||||
$rootScope.addSongsToQueue();
|
||||
|
@ -282,6 +277,7 @@ angular.module('JamStash')
|
|||
player.play(next);
|
||||
};
|
||||
$rootScope.playFrom = function (index, songs) {
|
||||
// TODO: Hyz: Replace
|
||||
var from = songs.slice(index,songs.length);
|
||||
$scope.selectedSongs = [];
|
||||
angular.forEach(from, function (item, key) {
|
||||
|
@ -296,6 +292,7 @@ angular.module('JamStash')
|
|||
}
|
||||
};
|
||||
$rootScope.addSongsToQueue = function () {
|
||||
// TODO: Hyz: Replace
|
||||
if ($scope.selectedSongs.length !== 0) {
|
||||
angular.forEach($scope.selectedSongs, function (item, key) {
|
||||
$rootScope.queue.push(item);
|
||||
|
@ -306,6 +303,7 @@ angular.module('JamStash')
|
|||
}
|
||||
};
|
||||
$rootScope.removeSong = function (item, songs) {
|
||||
// TODO: Hyz: Replace
|
||||
var index = songs.indexOf(item);
|
||||
songs.splice(index, 1);
|
||||
};
|
||||
|
@ -337,17 +335,6 @@ angular.module('JamStash')
|
|||
}
|
||||
});
|
||||
};
|
||||
$scope.queueTotal = function () {
|
||||
var total = 0;
|
||||
utils.arrayForEach(self.queue(), function (item) {
|
||||
total += parseInt(item.duration());
|
||||
});
|
||||
if (self.queue().length > 0) {
|
||||
return self.queue().length + ' song(s), ' + utils.secondsToTime(total) + ' total time';
|
||||
} else {
|
||||
return '0 song(s), 00:00:00 total time';
|
||||
}
|
||||
};
|
||||
$scope.selectedSongs = [];
|
||||
$scope.selectSong = function (data) {
|
||||
var i = $scope.selectedSongs.indexOf(data);
|
||||
|
@ -419,6 +406,7 @@ angular.module('JamStash')
|
|||
if (song) {
|
||||
player.load(song);
|
||||
}
|
||||
if (globals.settings.Debug) { console.log('Current Position Loaded from localStorage: ', song); }
|
||||
};
|
||||
|
||||
$scope.loadQueue = function () {
|
||||
|
|
|
@ -221,23 +221,6 @@ describe("Player service -", function() {
|
|||
};
|
||||
});
|
||||
|
||||
xit("when I play it, the song is marked as playing", function() {
|
||||
player.play(song);
|
||||
|
||||
expect(player.getPlayingSong()).toBe(song);
|
||||
expect(song.playing).toBeTruthy();
|
||||
});
|
||||
|
||||
xit("when I restart the current song, the song is still marked as playing", function() {
|
||||
song.playing = true;
|
||||
//player.getPlayingSong() = song;
|
||||
|
||||
player.restart();
|
||||
|
||||
expect(player.getPlayingSong()).toBe(song);
|
||||
expect(song.playing).toBeTruthy();
|
||||
});
|
||||
|
||||
it("when the song was playing and I play it again, it restarts the current song", function() {
|
||||
spyOn(player, "restart");
|
||||
|
||||
|
|
|
@ -17,19 +17,19 @@
|
|||
</div>
|
||||
<div id="songdetails">
|
||||
<div id="coverart">
|
||||
<a ng-click="fancyboxOpenImage(playingSong.coverartfull)">
|
||||
<img ng-src="{{player.playingSong.coverartthumb}}" src="images/albumdefault_60.jpg" height="30" width="30" />
|
||||
<a ng-click="fancyboxOpenImage(getPlayingSong().coverartfull)">
|
||||
<img ng-src="{{getPlayingSong().coverartthumb}}" src="images/albumdefault_60.jpg" height="30" width="30" />
|
||||
</a>
|
||||
</div>
|
||||
<ul>
|
||||
<li class="song" id="{{player.playingSong.id}}" ng-bind-html="player.playingSong.name" title="{{player.playingSong.specs}}"></li>
|
||||
<li class="album" ng-bind-html="player.playingSong.album"></li>
|
||||
<li class="song" id="{{getPlayingSong().id}}" ng-bind-html="getPlayingSong().name" title="{{getPlayingSong().specs}}"></li>
|
||||
<li class="album" ng-bind-html="getPlayingSong().album"></li>
|
||||
</ul>
|
||||
<div id="songdetails_controls">
|
||||
<a href="" class="jukebox" title="Jukebox Mode [Beta]" ng-click="toggleSetting('Jukebox')" ng-class="{'hoverSelected': !settings.Jukebox }"></a>
|
||||
<a href="" class="loop" title="Repeat" ng-click="toggleSetting('Repeat')" ng-class="{'hoverSelected': !settings.Repeat }"></a>
|
||||
<a href="" id="action_SaveProgress" class="lock" title="Save Track Position: On" ng-show="settings.SaveTrackPosition"></a>
|
||||
<a title="Favorite" href="" ng-class="{'favorite': player.playingSong.starred, 'rate': !player.playingSong.starred}" ng-click="updateFavorite(player.playingSong)" stop-event="click"></a>
|
||||
<a title="Favorite" href="" ng-class="{'favorite': getPlayingSong().starred, 'rate': !getPlayingSong().starred}" ng-click="updateFavorite(getPlayingSong())" stop-event="click"></a>
|
||||
<a href="" id="action_Mute" class="mute" title="Mute"></a>
|
||||
<a href="" id="action_UnMute" class="unmute" title="Unmute" style="display: none;"></a>
|
||||
<!--<div class="jp-volume-bar"><div class="jp-volume-bar-value"></div></div><a href="" id="action_VolumeMax" class="volume" title="Max Volume"></a>-->
|
||||
|
|
|
@ -10,7 +10,9 @@ angular.module('jamstash.player.controller', ['jamstash.player.service', 'jamsta
|
|||
|
||||
$scope.player = player;
|
||||
|
||||
$scope.updateFavorite = function (song) {
|
||||
// TODO
|
||||
$scope.getPlayingSong = function () {
|
||||
return player.getPlayingSong();
|
||||
};
|
||||
|
||||
//TODO: Hyz: updateFavorite - leave in rootScope ?
|
||||
}]);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div id="SideQueue">
|
||||
<ul class="simplelist songlist noselect">
|
||||
<div ng-repeat="song in [player.queue] track by $index" class="songs" sortable>
|
||||
<li class="row song" ng-repeat="o in song" ng-click="selectSong(o)" ng-dblclick="playSong(o)" ng-class="{'selected': o.selected, 'playing': o.playing}">
|
||||
<li class="row song" ng-repeat="o in song" ng-click="selectSong(o)" ng-dblclick="playSong(o)" ng-class="{'selected': o.selected, 'playing': isPlayingSong(o)}">
|
||||
<div class="itemactions">
|
||||
<a class="remove" href="" title="Remove Song" ng-click="removeSongFromQueue(o)" stop-event="click"></a>
|
||||
<a href="" title="Favorite" ng-class="{'favorite': o.starred, 'rate': !o.starred}" ng-click="updateFavorite(o)" stop-event="click"></a>
|
||||
|
|
|
@ -32,4 +32,10 @@ angular.module('jamstash.queue.controller', ['jamstash.player.service'])
|
|||
$scope.removeSelectedSongsFromQueue = function () {
|
||||
player.removeSongs($scope.selectedSongs);
|
||||
};
|
||||
|
||||
$scope.isPlayingSong = function (song) {
|
||||
return angular.equals(song, player.getPlayingSong());
|
||||
};
|
||||
|
||||
//TODO: Hyz: updateFavorite - leave in rootScope ?
|
||||
}]);
|
||||
|
|
|
@ -2,9 +2,7 @@ describe("Queue controller", function() {
|
|||
'use strict';
|
||||
|
||||
var player, scope, globals;
|
||||
var song = {
|
||||
id: 7310
|
||||
};
|
||||
var song;
|
||||
|
||||
beforeEach(function() {
|
||||
module('jamstash.queue.controller');
|
||||
|
@ -20,6 +18,7 @@ describe("Queue controller", function() {
|
|||
player: player
|
||||
});
|
||||
});
|
||||
song = { id: 7310 };
|
||||
});
|
||||
|
||||
it("When I play a song, it calls play in the player service", function() {
|
||||
|
@ -59,4 +58,10 @@ describe("Queue controller", function() {
|
|||
scope.removeSelectedSongsFromQueue();
|
||||
expect(player.removeSongs).toHaveBeenCalledWith([song, secondSong]);
|
||||
});
|
||||
|
||||
it("asks the player service if a given song is the currently playing song", function() {
|
||||
spyOn(player, "getPlayingSong").and.returnValue(song);
|
||||
expect(scope.isPlayingSong(song)).toBeTruthy();
|
||||
expect(player.getPlayingSong).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue