Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added ability to jump to a track (and list all tracks).

  • Loading branch information...
commit 60bbbacee6bc06535f084d56fc25233234d7c168 1 parent 572d18b
@malthe authored
Showing with 27 additions and 1 deletion.
  1. +27 −1 mdplayer.py
View
28 mdplayer.py
@@ -126,6 +126,10 @@ def prev(self):
self.number -= 2
self.event.set()
+ def jump(self, number):
+ self.number = number
+ self.event.set()
+
def sync(self):
mtime = os.path.getmtime(self.filename)
if self._last_read == mtime:
@@ -156,6 +160,26 @@ def __init__(self, filename):
def emptyline(self):
pass
+ def precmd(self, line):
+ try:
+ number = int(line)
+ except ValueError:
+ return line
+ return "j %d" % number
+
+ def do_j(self, message):
+ try:
+ number = int(message)
+ except ValueError:
+ print "Not an integer: %s." % message
+ self.queue.jump(number-1)
+
+ def do_l(self, message):
+ padding = len(str(len(self.queue.tracks)))
+ print "\n".join(
+ ("%%#0%dd %%s" % padding) % (i+1, track)
+ for (i, track) in enumerate(self.queue.tracks))
+
def do_p(self, message):
self.queue.prev()
@@ -170,7 +194,9 @@ def do_q(self, message):
return 1
if __name__ == "__main__":
- print "PLAY: p - previous; n - next; r - repeat; q - quit."
+ print "PLAY: p - previous; n - next; j - jump; r - repeat; l - list; q - quit."
+ print " jump to any track by entering its track number."
+ print "-----------------------------------------------------------------------"
console = Console(filename)
console.cmdloop()
Please sign in to comment.
Something went wrong with that request. Please try again.