Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/audio.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2014-01-02 18:44:25 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2014-01-02 18:44:25 (GMT)
commit6c86b2599b920c5ff6458f8645e6bf1cf0b9efea (patch)
tree1b233cfdc3dfd9203e1d081a6a01db3e3b0889d0 /audio.py
parent9eb392ce160ceb7859251dc7cdf8d94e02ad40b3 (diff)
Port espeak gstreamer part to use dynamic bindings
Now we don't draw the mouth, then the code can be simplified Signed-off-by: Ignacio Rodriguez <ignacio@sugarlabs.org> Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'audio.py')
-rw-r--r--audio.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/audio.py b/audio.py
index ddee412..edc9872 100644
--- a/audio.py
+++ b/audio.py
@@ -1,4 +1,5 @@
# Copyright (C) 2006, 2007, 2008 One Laptop Per Child
+# Copyright (C) 2013, Ignacio Rodriguez
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,16 +16,18 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-import gst
+from gi.repository import Gst
import logging
_logger = logging.getLogger('memorize-activity')
+Gst.init([])
+
class Audio(object):
def __init__(self):
- self._player = gst.element_factory_make('playbin', 'player')
- fakesink = gst.element_factory_make('fakesink', 'my-fakesink')
+ self._player = Gst.ElementFactory.make('playbin', 'player')
+ fakesink = Gst.ElementFactory.make('fakesink', 'my-fakesink')
self._player.set_property('video-sink', fakesink)
self._playing = None
@@ -36,28 +39,28 @@ class Audio(object):
if filename:
_logger.debug('play audio %s' % filename)
self._player.set_property('uri', 'file://' + filename)
- self._player.set_state(gst.STATE_NULL)
+ self._player.set_state(Gst.State.NULL)
elif self._playing == None:
return
else:
_logger.debug('continue audio')
- self._player.set_state(gst.STATE_PLAYING)
+ self._player.set_state(Gst.State.PLAYING)
self._playing = True
def pause(self):
if self._playing != None:
_logger.debug('pause audio')
- self._player.set_state(gst.STATE_PAUSED)
+ self._player.set_state(Gst.State.PAUSED)
self._playing = False
def stop(self):
- self._player.set_state(gst.STATE_NULL)
+ self._player.set_state(Gst.State.NULL)
def _gstmessage_cb(self, bus, message):
message_type = message.type
- if message_type in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR):
- self._player.set_state(gst.STATE_NULL)
+ if message_type in (Gst.MessageType.EOS, Gst.MessageType.ERROR):
+ self._player.set_state(Gst.State.NULL)
self._playing = None
_logger.debug('audio stoped with type %d' % message_type)