From 12e49b3c8807febb18da61b87d181ed2933b0768 Mon Sep 17 00:00:00 2001 From: Carl Suster Date: Mon, 1 Apr 2019 17:51:21 +1100 Subject: [PATCH] bpd: skipping backwards through zero keeps playing Previously issuing the 'previous' command when at position 0 on the playlist would cause bpd to stop playing. MPD instead just restarts the currently playing song instead, so we now match this behaviour. --- beetsplug/bpd/__init__.py | 5 ++--- test/test_player.py | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/beetsplug/bpd/__init__.py b/beetsplug/bpd/__init__.py index 9b21fae9d..ad2a3f921 100644 --- a/beetsplug/bpd/__init__.py +++ b/beetsplug/bpd/__init__.py @@ -554,9 +554,8 @@ class BaseServer(object): """Step back to the last song.""" self.current_index = self._prev_idx() if self.current_index < 0: - return self.cmd_stop(conn) - else: - return self.cmd_play(conn) + self.current_index = 0 + return self.cmd_play(conn) def cmd_pause(self, conn, state=None): """Set the pause state playback.""" diff --git a/test/test_player.py b/test/test_player.py index 5e196debd..b4c5c1cd0 100644 --- a/test/test_player.py +++ b/test/test_player.py @@ -519,7 +519,7 @@ class BPDPlaybackTest(BPDTestHelper): class BPDControlTest(BPDTestHelper): test_implements_control = implements({ - 'pause', 'playid', 'previous', 'seek', + 'pause', 'playid', 'seek', 'seekid', 'seekcur', 'stop', }, expectedFailure=True) @@ -552,6 +552,23 @@ class BPDControlTest(BPDTestHelper): self.assertEqual('2', responses[3].data['Id']) self.assertEqual('stop', responses[5].data['state']) + def test_cmd_previous(self): + with self.run_bpd() as client: + self._bpd_add(client, self.item1, self.item2) + responses = client.send_commands( + ('play', '1'), + ('currentsong',), + ('previous',), + ('currentsong',), + ('previous',), + ('status',), + ('currentsong',)) + self._assert_ok(*responses) + self.assertEqual('2', responses[1].data['Id']) + self.assertEqual('1', responses[3].data['Id']) + self.assertEqual('play', responses[5].data['state']) + self.assertEqual('1', responses[6].data['Id']) + class BPDQueueTest(BPDTestHelper): test_implements_queue = implements({