Skip to content
Browse files

Implemented skipping tracks in client

  • Loading branch information...
1 parent 2be3036 commit 3e1ece9d14daf5e5eab2e6b4494a213baa009c86 @dbrgn committed Apr 5, 2013
Showing with 13 additions and 4 deletions.
  1. +13 −4 orochi/client.py
View
17 orochi/client.py
@@ -110,13 +110,13 @@ def __init__(self, mix_id, parent_cmd, *args, **kwargs):
r = super(PlayCommand, self).__init__(*args, **kwargs)
# Initialize mplayer slave session with line buffer
- self.p = Process(['mplayer', '-slave', '-quiet', '-idle'], bufsize=1)
+ self.p = Process(['mplayer', '-slave', '-quiet', '-idle', '-cache', '1024'], bufsize=1)
# Play first track at max volume
self.status = self.api.play_mix(mix_id)
self._play(self.status['track']['url'])
self.p.write('volume {} 1\n'.format(self.parent_cmd.volume))
- self.do_status('')
+ self.do_status()
return r
@@ -152,7 +152,7 @@ def _play(self, url):
if time.time() - start > LOADFILE_TIMEOUT:
raise RuntimeError("Playback didn't start inside {}s. ".format(LOADFILE_TIMEOUT) +
"Something must have gone wrong.", self.p.readerr())
- time.sleep(0.05)
+ time.sleep(0.1)
def do_pause(self, s):
self.p.write('pause\n')
@@ -169,6 +169,15 @@ def do_stop(self, s):
def help_stop(self):
print('Stop the playback and exit play mode.')
+ def do_skip(self, s):
+ print('Skipping track...')
+ self.status = self.api.skip_track(self.mix_id)
+ self._play(self.status['track']['url'])
+ self.do_status()
+
+ def help_skip(self):
+ print('Skip the current song.')
+
def do_volume(self, s):
try:
vol = int(s)
@@ -183,7 +192,7 @@ def help_volume(self):
print('Syntax: volume <amount>')
print('Change playback volume. The argument must be a number between 0 and 100.')
- def do_status(self, s):
+ def do_status(self, s=''):
track = self.status['track']
print('Now playing "{0[name]}" by "{0[performer]}".'.format(track))

0 comments on commit 3e1ece9

Please sign in to comment.
Something went wrong with that request. Please try again.