[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/7] player: implement previous/next commands
From: |
Eric Wong |
Subject: |
[PATCH 4/7] player: implement previous/next commands |
Date: |
Mon, 9 Sep 2013 08:31:06 +0000 |
This means we can go back and forth in the tracklist like a normal
music player. This will allow an easier MPRIS 2.0 implementation.
---
lib/dtas/player/client_handler.rb | 7 +++++++
lib/dtas/tracklist.rb | 6 ++++++
2 files changed, 13 insertions(+)
diff --git a/lib/dtas/player/client_handler.rb
b/lib/dtas/player/client_handler.rb
index 355451d..33cae05 100644
--- a/lib/dtas/player/client_handler.rb
+++ b/lib/dtas/player/client_handler.rb
@@ -583,6 +583,13 @@ module DTAS::Player::ClientHandler # :nodoc:
when "current-id"
path = @tl.cur_track
io.emit(path ? path.object_id.to_s : "NONE")
+ when "next"
+ _tl_skip
+ io.emit("OK")
+ when "previous"
+ @tl.previous!
+ _tl_skip
+ io.emit("OK")
end
end
end
diff --git a/lib/dtas/tracklist.rb b/lib/dtas/tracklist.rb
index e0b00cb..c3cd3ff 100644
--- a/lib/dtas/tracklist.rb
+++ b/lib/dtas/tracklist.rb
@@ -114,4 +114,10 @@ class DTAS::Tracklist
@goto_pos = nil
# noop if track_id is invalid
end
+
+ def previous!
+ return if @list.empty?
+ prev_idx = @pos - 1
+ @goto_pos = @list[prev_idx] ? prev_idx : nil
+ end
end
--
1.8.4
- [PATCH 1/7] dtas-console: avoid using current if it is nil, Eric Wong, 2013/09/09
- [PATCH 3/7] tracklist: next_track -> advance_track, Eric Wong, 2013/09/09
- [PATCH 5/7] player: "tl goto" takes optional offset arg in HHMMSS.SUBSEC, Eric Wong, 2013/09/09
- [PATCH 7/7] tracklist: implement single-track repeat, Eric Wong, 2013/09/09
- [PATCH 2/7] player: reset tracklist when idle stat is detected, Eric Wong, 2013/09/09
- [PATCH 6/7] tracklist: previous! only wraps around when repeat is enabled, Eric Wong, 2013/09/09
- [PATCH 4/7] player: implement previous/next commands,
Eric Wong <=