diff options
author | Eric Wong <e@80x24.org> | 2016-01-05 09:32:09 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-01-05 09:49:43 +0000 |
commit | e87a0231846ca1ef79eff07233025989693131d2 (patch) | |
tree | 42161a9d46de89e3deb691afa5a6512ad20f0cb8 /lib | |
parent | d5044386bf829125f948b6a706d9c590a60e9791 (diff) | |
download | dtas-e87a0231846ca1ef79eff07233025989693131d2.tar.gz |
For now, shuffle means "random without repeats". So avoid repeating ourselves by shuffling when we've reached the end of the shuffled tracklist and have no more tracks to go. Whenever a client restarts the player or hits the loop for repeat, we'll have a freshly shuffled list for them to listen to.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dtas/tracklist.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/dtas/tracklist.rb b/lib/dtas/tracklist.rb index 68e88f2..6e0dd75 100644 --- a/lib/dtas/tracklist.rb +++ b/lib/dtas/tracklist.rb @@ -123,10 +123,11 @@ class DTAS::Tracklist # :nodoc: @goto_pos = @goto_off = nil if cur[next_pos] @pos = next_pos - elsif repeat - next_pos = @pos = 0 else - return + # reshuffle the tracklist when we've exhausted it + cur.shuffle! if @shuffle + return unless repeat + next_pos = @pos = 0 end [ cur[next_pos].to_path, next_off ] end |