From: Antonio Ospite <ao2@ao2.it>
Date: Mon, 28 Nov 2016 12:35:58 +0000 (+0100)
Subject: Handle KeyboardInterrupt in the main program, not in the Player class
X-Git-Url: https://git.ao2.it/vidi-player.git/commitdiff_plain/053eff8c0013a6ad620b1d29638133fdaff5c7f5?ds=inline;hp=6260f5eebfa3a865de0cecb78986d75bb1b661e1

Handle KeyboardInterrupt in the main program, not in the Player class
---

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()