From c5428cf32714d9e81343ba6b3a5d24a12088b968 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 24 Oct 2013 19:38:58 +0200 Subject: [PATCH] add OSC pause mode, fix OSC stop --- piplayer/player.py | 16 +++++++++++++--- tools/osc_stop.py | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/piplayer/player.py b/piplayer/player.py index 7fab497..74e7577 100644 --- a/piplayer/player.py +++ b/piplayer/player.py @@ -57,8 +57,8 @@ class PiPlayer(object): # OSC controller self.osc_controller = OSCController(self.osc_port) - self.osc_controller.add_method('/play', 'i', self.osc_play_stop) - self.osc_controller.add_method('/stop', 'i', self.osc_play_stop) + self.osc_controller.add_method('/play', 'i', self.osc_play_pause) + self.osc_controller.add_method('/stop', 'i', self.osc_stop) self.osc_controller.start() # GPIO controller @@ -174,11 +174,21 @@ class PiPlayer(object): self.pipeline.set_state(gst.STATE_NULL) self.playing = False - def osc_play_stop(self, path, value): + def pause(self): + if self.playing: + self.pipeline.set_state(gst.STATE_PAUSED) + self.playing = False + + def osc_play_pause(self, path, value): value = value[0] if value and not self.playing: self.play() else: + self.pause() + + def osc_stop(self, path, value): + value = value[0] + if value and self.playing: self.stop() def gpio_play(self, channel): diff --git a/tools/osc_stop.py b/tools/osc_stop.py index cce3314..acb1ea1 100644 --- a/tools/osc_stop.py +++ b/tools/osc_stop.py @@ -11,4 +11,4 @@ except liblo.AddressError, err: sys.exit() # send message "/foo/message1" with int, float and string arguments -liblo.send(target, "/play", 0) +liblo.send(target, "/stop", 1) -- 2.39.5