diff --git a/public/templates/directives/player.html b/public/templates/directives/player.html
index 0ca8aaa4..39806962 100644
--- a/public/templates/directives/player.html
+++ b/public/templates/directives/player.html
@@ -12,7 +12,7 @@
-
+ {{ repeatText }}
diff --git a/resources/assets/scripts/app/directives/player.coffee b/resources/assets/scripts/app/directives/player.coffee
index 996d47a2..0e7387c8 100644
--- a/resources/assets/scripts/app/directives/player.coffee
+++ b/resources/assets/scripts/app/directives/player.coffee
@@ -30,6 +30,7 @@ module.exports = angular.module('ponyfm').directive 'pfmPlayer', () ->
($scope, player, auth) ->
$scope.player = player
$scope.auth = auth.data
+ $scope.repeatText = ''
$scope.playPause = () ->
$scope.player.playPause()
@@ -42,6 +43,11 @@ module.exports = angular.module('ponyfm').directive 'pfmPlayer', () ->
$scope.toggleRepeat = () ->
$scope.player.toggleRepeat()
+ if $scope.player.repeatState == 2
+ $scope.repeatText = '1'
+ else
+ $scope.repeatText = ''
+
$scope.seek = (e) ->
$transport = $ '.transport'
percent = ((e.pageX - $transport.offset().left) / $transport.width())
diff --git a/resources/assets/scripts/app/services/player.coffee b/resources/assets/scripts/app/services/player.coffee
index 7b6f0c58..e1051dad 100644
--- a/resources/assets/scripts/app/services/player.coffee
+++ b/resources/assets/scripts/app/services/player.coffee
@@ -44,7 +44,10 @@ module.exports = angular.module('ponyfm').factory('player', [
track.progress = (self.currentSound.position / (track.duration * 1000)) * 100
onfinish: () -> $rootScope.safeApply ->
- if self.repeatOnce
+ if self.repeatState == 2
+ # Track repeat
+ # Playlist repeat is handled
+ # in self.playNext()
self.currentSound.play()
else
track.isPlaying = false
@@ -82,7 +85,7 @@ module.exports = angular.module('ponyfm').factory('player', [
readyDef: readyDef.promise()
canGoPrev: false
canGoNext: false
- repeatOnce: false
+ repeatState: 0
playPause: () ->
return if !self.ready
@@ -94,16 +97,19 @@ module.exports = angular.module('ponyfm').factory('player', [
self.currentSound.pause()
playNext: () ->
- return if !self.canGoNext
+ return if !self.canGoNext && self.repeatState != 1
self.currentSound.stop() if self.currentSound != null
self.playlistIndex++
if self.playlistIndex >= self.playlist.length
- self.playlist.length = 0
- self.currentTrack = null
- self.currentSong = null
- self.isPlaying = false
- return
+ if self.repeatState != 1
+ self.playlist.length = 0
+ self.currentTrack = null
+ self.currentSong = null
+ self.isPlaying = false
+ return
+ else
+ self.playlistIndex = 0
play self.playlist[self.playlistIndex]
updateCanGo()
@@ -125,7 +131,10 @@ module.exports = angular.module('ponyfm').factory('player', [
updateCanGo()
toggleRepeat: () ->
- self.repeatOnce = !self.repeatOnce
+ if self.repeatState >= 2
+ self.repeatState = 0
+ else
+ self.repeatState++
seek: (progress) ->
return if !self.currentSound
diff --git a/resources/assets/styles/components/player.less b/resources/assets/styles/components/player.less
index 7ea7a61a..800613e6 100644
--- a/resources/assets/styles/components/player.less
+++ b/resources/assets/styles/components/player.less
@@ -167,9 +167,9 @@ body.is-logged {
}
}
- > a.active {
+ > a.repeat.active {
text-decoration: none;
- background: darken(#eee, 10%);
+ background: darken(#eee, 5%);
color: #000;
}