From 053eff8c0013a6ad620b1d29638133fdaff5c7f5 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 28 Nov 2016 13:35:58 +0100 Subject: [PATCH 1/1] Handle KeyboardInterrupt in the main program, not in the Player class --- vidi-player.py | 6 +++++- vidi/Player.py | 9 +-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/vidi-player.py b/vidi-player.py index 04c8941..62ae575 100755 --- a/vidi-player.py +++ b/vidi-player.py @@ -105,7 +105,11 @@ def main(): if len(sys.argv) > 3: timeline.save(sys.argv[3]) else: - timeline.play() + try: + timeline.play() + except KeyboardInterrupt: + timeline.stop() + return 1 if __name__ == "__main__": diff --git a/vidi/Player.py b/vidi/Player.py index 58c3ece..15a4d07 100755 --- a/vidi/Player.py +++ b/vidi/Player.py @@ -51,11 +51,4 @@ class Player(object): def play(self): self.pipeline.set_state(Gst.State.PLAYING) - - try: - self.mainloop.run() - except KeyboardInterrupt: - self.stop() - return 1 - - return 0 + self.mainloop.run() -- 2.1.4