[pitivi/ges: 93/287] utils: Add a togglePipeline utility function
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/ges: 93/287] utils: Add a togglePipeline utility function
- Date: Thu, 15 Mar 2012 16:33:38 +0000 (UTC)
commit 5031f34001af5bf22d7871e6bf2a9d1cc472daf7
Author: Thibault Saunier <thibault saunier collabora com>
Date: Wed Dec 14 13:10:55 2011 -0300
utils: Add a togglePipeline utility function
Make use of it in the viewer
pitivi/ui/viewer.py | 22 +++++-----------------
pitivi/utils.py | 17 +++++++++++++++++
2 files changed, 22 insertions(+), 17 deletions(-)
---
diff --git a/pitivi/ui/viewer.py b/pitivi/ui/viewer.py
index 7668d0c..d6f05d8 100644
--- a/pitivi/ui/viewer.py
+++ b/pitivi/ui/viewer.py
@@ -29,7 +29,7 @@ import cairo
from gettext import gettext as _
-from pitivi.utils import time_to_string
+from pitivi.utils import time_to_string, togglePlayback
from pitivi.log.loggable import Loggable
from pitivi.ui.common import SPACING, hex_to_rgb
from pitivi.settings import GlobalSettings
@@ -488,12 +488,7 @@ class PitiviViewer(gtk.VBox, Loggable):
self.seekRelative(0 - gst.SECOND)
def _playButtonCb(self, unused_button, playing):
- if playing:
- self.playing = True
- self.pipeline.set_state(gst.STATE_PLAYING)
- else:
- self.playing = False
- self.pipeline.set_state(gst.STATE_PAUSED)
+ self.togglePlayback()
def _forwardCb(self, unused_button):
self.seekRelative(gst.SECOND)
@@ -520,16 +515,9 @@ class PitiviViewer(gtk.VBox, Loggable):
self.pipeline.pause()
def togglePlayback(self):
- if self.pipeline is None:
- return
-
- if int(self.pipeline.get_state()[1]) == int(gst.STATE_PLAYING):
- state = gst.STATE_PAUSED
- self.playpause_button.setPause()
- else:
- self.playpause_button.setPlay()
- state = gst.STATE_PLAYING
- self.pipeline.set_state(state)
+ if self.pipeline:
+ state = togglePlayback(self.pipeline)
+ self.playing = (state == gst.STATE_PLAYING)
def undock(self):
if not self.undock_action:
diff --git a/pitivi/utils.py b/pitivi/utils.py
index 80223dd..9de4a1c 100644
--- a/pitivi/utils.py
+++ b/pitivi/utils.py
@@ -532,3 +532,20 @@ def show_user_manual():
continue
log.warning("utils", "Failed loading URIs")
# TODO: Show an error message to the user.
+
+
+#-----------------------------------------------------------------------------#
+# Pipeline utils #
+def togglePlayback(pipeline):
+ if int(pipeline.get_state()[1]) == int(gst.STATE_PLAYING):
+ state = gst.STATE_PAUSED
+ else:
+ state = gst.STATE_PLAYING
+
+ res = pipeline.set_state(state)
+ if res == gst.STATE_CHANGE_FAILURE:
+ gst.error("Could no set state to %s")
+ state = gst.STATE_NULL
+ pipeline.set_state(state)
+
+ return state
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]