mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-02-18 02:54:21 +01:00
disabled buttons when cannot go forward/back
This commit is contained in:
parent
f4ee6c8add
commit
9e358a3fdc
3 changed files with 27 additions and 2 deletions
|
@ -38,6 +38,10 @@ angular.module('ponyfm').factory('player', [
|
||||||
self.isPlaying = true
|
self.isPlaying = true
|
||||||
self.currentSound.play()
|
self.currentSound.play()
|
||||||
|
|
||||||
|
updateCanGo = () ->
|
||||||
|
self.canGoNext = self.playlistIndex < self.playlist.length - 1
|
||||||
|
self.canGoPrev = self.playlistIndex > 0
|
||||||
|
|
||||||
self =
|
self =
|
||||||
ready: false
|
ready: false
|
||||||
isPlaying: false
|
isPlaying: false
|
||||||
|
@ -47,6 +51,8 @@ angular.module('ponyfm').factory('player', [
|
||||||
playlistIndex: 0
|
playlistIndex: 0
|
||||||
volume: 0
|
volume: 0
|
||||||
readyDef: readyDef.promise()
|
readyDef: readyDef.promise()
|
||||||
|
canGoPrev: false
|
||||||
|
canGoNext: false
|
||||||
|
|
||||||
playPause: () ->
|
playPause: () ->
|
||||||
return if !self.ready
|
return if !self.ready
|
||||||
|
@ -58,6 +64,8 @@ angular.module('ponyfm').factory('player', [
|
||||||
self.currentSound.pause()
|
self.currentSound.pause()
|
||||||
|
|
||||||
playNext: () ->
|
playNext: () ->
|
||||||
|
return if !self.canGoNext
|
||||||
|
|
||||||
self.currentSound.stop() if self.currentSound != null
|
self.currentSound.stop() if self.currentSound != null
|
||||||
self.playlistIndex++
|
self.playlistIndex++
|
||||||
if self.playlistIndex >= self.playlist.length
|
if self.playlistIndex >= self.playlist.length
|
||||||
|
@ -68,8 +76,11 @@ angular.module('ponyfm').factory('player', [
|
||||||
return
|
return
|
||||||
|
|
||||||
play self.playlist[self.playlistIndex]
|
play self.playlist[self.playlistIndex]
|
||||||
|
updateCanGo()
|
||||||
|
|
||||||
playPrev: () ->
|
playPrev: () ->
|
||||||
|
return if !self.canGoPrev
|
||||||
|
|
||||||
self.currentSound.stop() if self.currentSound != null
|
self.currentSound.stop() if self.currentSound != null
|
||||||
self.playlistIndex--
|
self.playlistIndex--
|
||||||
if self.playlistIndex <= 0
|
if self.playlistIndex <= 0
|
||||||
|
@ -80,6 +91,7 @@ angular.module('ponyfm').factory('player', [
|
||||||
return
|
return
|
||||||
|
|
||||||
play self.playlist[self.playlistIndex]
|
play self.playlist[self.playlistIndex]
|
||||||
|
updateCanGo()
|
||||||
|
|
||||||
seek: (progress) ->
|
seek: (progress) ->
|
||||||
return if !self.currentSound
|
return if !self.currentSound
|
||||||
|
@ -108,6 +120,7 @@ angular.module('ponyfm').factory('player', [
|
||||||
|
|
||||||
$rootScope.$broadcast 'player-starting-playlist', tracks
|
$rootScope.$broadcast 'player-starting-playlist', tracks
|
||||||
play tracks[index]
|
play tracks[index]
|
||||||
|
updateCanGo()
|
||||||
|
|
||||||
pfm.soundManager.done () ->
|
pfm.soundManager.done () ->
|
||||||
self.ready = true
|
self.ready = true
|
||||||
|
|
|
@ -112,6 +112,18 @@ body.is-logged {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
a {
|
||||||
|
color: #ccc;
|
||||||
|
cursor: default;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: transparent;
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.volume {
|
&.volume {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
<strong>{{player.currentTrack.progressSeconds | secondsDisplay}}</strong> /
|
<strong>{{player.currentTrack.progressSeconds | secondsDisplay}}</strong> /
|
||||||
<strong>{{player.currentTrack.duration | secondsDisplay}}</strong>
|
<strong>{{player.currentTrack.duration | secondsDisplay}}</strong>
|
||||||
</li>
|
</li>
|
||||||
<li><a pfm-eat-click ng-click="playPrev()" class="previous" href="#"><i class="icon-fast-backward"></i></a></li>
|
<li ng-class="{disabled: !player.canGoPrev}"><a pfm-eat-click ng-click="playPrev()" class="previous" href="#"><i class="icon-fast-backward"></i></a></li>
|
||||||
<li>
|
<li>
|
||||||
<a pfm-eat-click ng-click="playPause()" class="play" href="#">
|
<a pfm-eat-click ng-click="playPause()" class="play" href="#">
|
||||||
<i class="icon-pause" ng-show="player.currentTrack.isPlaying"></i>
|
<i class="icon-pause" ng-show="player.currentTrack.isPlaying"></i>
|
||||||
<i class="icon-play" ng-hide="player.currentTrack.isPlaying"></i>
|
<i class="icon-play" ng-hide="player.currentTrack.isPlaying"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a pfm-eat-click ng-click="playNext()" class="next" href="#"><i class="icon-fast-forward"></i></a></li>
|
<li ng-class="{disabled: !player.canGoNext}"><a pfm-eat-click ng-click="playNext()" class="next" href="#"><i class="icon-fast-forward"></i></a></li>
|
||||||
<li class="volume">
|
<li class="volume">
|
||||||
<a pfm-eat-click ng-click="" class="volume" href="#">
|
<a pfm-eat-click ng-click="" class="volume" href="#">
|
||||||
<i class="icon-volume-up"></i>
|
<i class="icon-volume-up"></i>
|
||||||
|
|
Loading…
Reference in a new issue