From 5484099e7cc3077ed2bb5631d0f2f33f6df1e483 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 9 Sep 2013 08:29:15 +0000 Subject: tracklist: implement single-track repeat Because sometimes a song is just stuck in our head. Or MPRIS 2.0 wants us to implement it this way... --- lib/dtas/player/client_handler.rb | 1 + lib/dtas/tracklist.rb | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/dtas') diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb index c7dd31d..9697f39 100644 --- a/lib/dtas/player/client_handler.rb +++ b/lib/dtas/player/client_handler.rb @@ -547,6 +547,7 @@ module DTAS::Player::ClientHandler # :nodoc: case msg.shift when "true" then @tl.repeat = true when "false" then @tl.repeat = false + when "1" then @tl.repeat = 1 when nil return io.emit("repeat #{@tl.repeat.to_s}") end diff --git a/lib/dtas/tracklist.rb b/lib/dtas/tracklist.rb index 644c57f..6ed22ee 100644 --- a/lib/dtas/tracklist.rb +++ b/lib/dtas/tracklist.rb @@ -6,7 +6,7 @@ require_relative 'serialize' # this is inspired by the MPRIS 2.0 TrackList spec class DTAS::Tracklist include DTAS::Serialize - attr_accessor :repeat + attr_accessor :repeat # true, false, 1 SIVS = %w(list pos repeat) TL_DEFAULTS = { @@ -67,7 +67,8 @@ class DTAS::Tracklist def advance_track(repeat_ok = true) return if @list.empty? - next_pos = @goto_pos || @pos + 1 + # @repeat == 1 for single track repeat + next_pos = @goto_pos || @pos + (@repeat == 1 ? 0 : 1) next_off = @goto_off # nil by default @goto_pos = @goto_off = nil if @list[next_pos] -- cgit v1.2.3-24-ge0c7