@@ -32,6 +32,18 @@ app.controller 'PlayerCtrl',['$scope', 'AuthFactory', 'ApiFactory', '$sce', '$ro
32
32
$scope .currentTime = data .currentTime
33
33
$scope .$on ' audio.play' , () -> $scope .playing = true
34
34
$scope .$on ' audio.pause' , () -> $scope .playing = false
35
+ $scope .$on ' audio.next' , () ->
36
+ index = _ .indexOf ($scope .current_playlist .songs , $scope .current_song )
37
+ $scope .current_song = $scope .current_playlist .songs [index + 1 ]
38
+ if ! $scope .current_song
39
+ $scope .current_song = $scope .current_playlist .songs [0 ]
40
+ playlist = $scope .current_playlist
41
+ song = $scope .current_song
42
+ if $scope .selectedSongs ().length == 1
43
+ $scope .last_clicked_song .selected = false
44
+ song .selected = true
45
+ $scope .last_clicked_song = song
46
+ $rootScope .$broadcast ' audio.set' , $sce .trustAsResourceUrl (song .file_url ), song, _ .indexOf (playlist .songs , song)+ 1 , playlist .songs .length
35
47
window .setInterval ( () ->
36
48
ApiFactory .updatePlayback ($scope .current_song .id , $scope .current_playlist .id , $scope .currentTime ) if $scope .playing
37
49
, 5000 )
@@ -85,12 +97,24 @@ app.controller 'PlayerCtrl',['$scope', 'AuthFactory', 'ApiFactory', '$sce', '$ro
85
97
alert val .errors .join (' , ' )
86
98
87
99
$scope .clickSong = (song ) ->
88
- if $scope . last_clicked_song . id == song . id
89
- $scope . playSong ( _ . indexOf ( $scope . current_playlist . songs , song))
90
- else
91
- $scope . last_clicked_song . selected = false
100
+ if song . dontgo == true
101
+ song . dontgo = false
102
+ else if window . ctrlDown
103
+ song . selected = ! song . selected
92
104
$scope .last_clicked_song = song
93
- song .selected = true
105
+ else if window .shiftDown
106
+ min = Math .min ($scope .last_clicked_song .id , song .id )
107
+ max = Math .max ($scope .last_clicked_song .id , song .id )
108
+ _ .each ($scope .current_playlist .songs , (song ) ->
109
+ song .selected = song .id <= max && song .id >= min
110
+ )
111
+ else
112
+ if $scope .last_clicked_song .id == song .id
113
+ $scope .playSong (_ .indexOf ($scope .current_playlist .songs , song))
114
+ else
115
+ _ .each ($scope .current_playlist .songs , (song ) -> song .selected = false )
116
+ $scope .last_clicked_song = song
117
+ song .selected = true
94
118
95
119
$scope .softClickSong = (song ) ->
96
120
if $scope .last_clicked_song
0 commit comments