From 2c06c058b7f9fd06f61b93fde8fbab496f42ae92 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Tue, 23 Jul 2013 03:02:35 +0200 Subject: [PATCH] first (one shot) play --- piplayer.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/piplayer.py b/piplayer.py index 83a7a84..c802fea 100644 --- a/piplayer.py +++ b/piplayer.py @@ -54,10 +54,9 @@ class OSCController(Thread): self.server.recv(100) -class AudioPlayer(Thread): +class AudioPlayer(object): def __init__(self, uri): - Thread.__init__(self) self.uri = uri @@ -67,9 +66,10 @@ class AudioPlayer(Thread): self.osc_controller.start() # GPIO Controller - self.gpio_channel = 0 - GPIO.setup(self.gpio_channel, GPIO.IN) - GPIO.add_event_detect(self.gpio_channel, GPIO.LOW, callback=self.gpio_play) + self.gpio_channel = 22 + #GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) + GPIO.setup(self.gpio_channel, GPIO.IN, pull_up_down=GPIO.PUD_UP) + GPIO.add_event_detect(self.gpio_channel, GPIO.PUD_UP, callback=self.gpio_play) # The pipeline self.pipeline = gst.Pipeline() @@ -138,7 +138,8 @@ class AudioPlayer(Thread): else: self.pipeline.set_state(gst.STATE_NULL) - def gpio_play(self): + def gpio_play(self, value): + print 'play' self.pipeline.set_state(gst.STATE_NULL) self.pipeline.set_state(gst.STATE_PLAYING) @@ -153,5 +154,5 @@ class AudioPlayer(Thread): if __name__ == '__main__': uri = sys.argv[-1] player = AudioPlayer(uri) - player.start() + player.run() -- 2.39.5