Commits

Friedrich Weber committed 71f04b2

added `pause`, changed `play`, fixed KeyboardInterrupt

Comments (0)

Files changed (3)

         while True:
             try:
                 self.cmdloop()
-            except (KeyboardInterrupt, SystemExit):
+            except KeyboardInterrupt:
+                self.jam.quit()
+            except SystemExit:
                 raise
             except:
                 print_exc()
         """
             `play [PLAYLIST]`
 
-            if PLAYLIST is not specified, play the 'jam' playlist
+            if PLAYLIST is not specified, resume the current playlist.
         """
-        playlist = positional[0] if len(positional) > 0 else 'jam'
-        self.play_playlist(playlist)
+        if len(positional) == 0:
+            self.player.play()
+        else:
+            playlist = positional[0]
+            self.play_playlist(playlist)
 
     def do_next(self, positional, keywords, additional):
         """
             for item in playlist:
                 print '  - %s' % repr(item)
 
+    def do_pause(self, positional, keywords, additional):
+        """
+            `pause`
+
+            pause the current stream. resume with `play`.
+        """
+        self.player.pause()
+
     def update_prompt(self):
         """
             sets the cli's prompt to the current liblet's full name
              * next
              * stop
              * playlists
+             * pause
 
         """
         bindings = [('quit', self.do_quit),
                     ('next', self.do_next),
                     ('stop', self.do_stop),
                     ('playlists', self.do_playlists),
+                    ('pause', self.do_pause),
                     ]
         for command, func in bindings:
             self.add_binding(command, func)

jambalah/player.py

         """
         self.playbin.set_state(gst.STATE_PLAYING)
 
+    def pause(self):
+        """
+            pause. you can make it play again with `play`.
+        """
+        self.playbin.set_state(gst.STATE_PAUSED)
+
     def play_iterator(self, iterator):
         """
             *iterator* is yielding urls. play all these.