mirror of
https://github.com/beetbox/beets.git
synced 2025-12-30 20:42:37 +01:00
bpd: support consume command
This commit is contained in:
parent
e5851866d7
commit
859e16d1e3
2 changed files with 33 additions and 1 deletions
|
|
@ -173,6 +173,7 @@ class BaseServer(object):
|
|||
# Default server values.
|
||||
self.random = False
|
||||
self.repeat = False
|
||||
self.consume = False
|
||||
self.volume = VOLUME_MAX
|
||||
self.crossfade = 0
|
||||
self.mixrampdb = 0.0
|
||||
|
|
@ -309,6 +310,7 @@ class BaseServer(object):
|
|||
u'volume: ' + six.text_type(self.volume),
|
||||
u'repeat: ' + six.text_type(int(self.repeat)),
|
||||
u'random: ' + six.text_type(int(self.random)),
|
||||
u'consume: ' + six.text_type(int(self.consume)),
|
||||
u'playlist: ' + six.text_type(self.playlist_version),
|
||||
u'playlistlength: ' + six.text_type(len(self.playlist)),
|
||||
u'mixrampdb: ' + six.text_type(self.mixrampdb),
|
||||
|
|
@ -350,6 +352,10 @@ class BaseServer(object):
|
|||
"""Set or unset repeat mode."""
|
||||
self.repeat = cast_arg('intbool', state)
|
||||
|
||||
def cmd_consume(self, conn, state):
|
||||
"""Set or unset consume mode."""
|
||||
self.consume = cast_arg('intbool', state)
|
||||
|
||||
def cmd_setvol(self, conn, vol):
|
||||
"""Set the player's volume level (0-100)."""
|
||||
vol = cast_arg(int, vol)
|
||||
|
|
@ -519,7 +525,12 @@ class BaseServer(object):
|
|||
|
||||
def cmd_next(self, conn):
|
||||
"""Advance to the next song in the playlist."""
|
||||
old_index = self.current_index
|
||||
self.current_index = self._succ_idx()
|
||||
if self.consume:
|
||||
self.playlist.pop(old_index)
|
||||
if self.current_index > old_index:
|
||||
self.current_index -= 1
|
||||
if self.current_index >= len(self.playlist):
|
||||
# Fallen off the end. Just move to stopped state.
|
||||
return self.cmd_stop(conn)
|
||||
|
|
|
|||
|
|
@ -361,10 +361,31 @@ class BPDQueryTest(BPDTestHelper):
|
|||
|
||||
class BPDPlaybackTest(BPDTestHelper):
|
||||
test_implements_playback = implements({
|
||||
'consume', 'random',
|
||||
'random',
|
||||
'repeat', 'single',
|
||||
}, expectedFailure=True)
|
||||
|
||||
def test_cmd_consume(self):
|
||||
with self.run_bpd() as client:
|
||||
self._bpd_add(client, self.item1, self.item2)
|
||||
responses = client.send_commands(
|
||||
('consume', '0'),
|
||||
('playlistinfo',),
|
||||
('next',),
|
||||
('playlistinfo',),
|
||||
('consume', '1'),
|
||||
('playlistinfo',),
|
||||
('play', '0'),
|
||||
('next',),
|
||||
('playlistinfo',),
|
||||
('status',))
|
||||
self._assert_ok(*responses)
|
||||
self.assertEqual(responses[1].data['Id'], responses[3].data['Id'])
|
||||
self.assertEqual(['1', '2'], responses[5].data['Id'])
|
||||
self.assertEqual('2', responses[8].data['Id'])
|
||||
self.assertEqual('1', responses[9].data['consume'])
|
||||
self.assertEqual('play', responses[9].data['state'])
|
||||
|
||||
def test_cmd_crossfade(self):
|
||||
with self.run_bpd() as client:
|
||||
responses = client.send_commands(
|
||||
|
|
|
|||
Loading…
Reference in a new issue