Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Sound.py
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-02-02 10:39:23 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-02-02 10:39:23 (GMT)
commitf5d3ebdc108980580569f32352cdb9c6de3a401c (patch)
tree0207cb219ed15aaa3042fb7b8eb97ee78382c0c4 /Sound.py
parenta4701d57c5a44fe943d01391dcaeac09df109fdf (diff)
Rename files
Diffstat (limited to 'Sound.py')
-rw-r--r--Sound.py125
1 files changed, 0 insertions, 125 deletions
diff --git a/Sound.py b/Sound.py
deleted file mode 100644
index 12b5ede..0000000
--- a/Sound.py
+++ /dev/null
@@ -1,125 +0,0 @@
-# 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
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import os
-import gtk
-import gst
-from glob import glob
-from gettext import gettext as _
-
-import Theme
-from Document import Document
-from Utils import *
-from sugar.activity.activity import get_bundle_path
-
-PREISTALLED = 0
-CUSTOM = 1
-TEMPORARY = 2
-JOURNAL = 3
-
-def load():
- if os.path.isabs(Document.sound_filename):
- custom = Sound(Document.sound_name, 'images/sounds/speaker.png',
- Document.sound_filename, TEMPORARY)
- THEMES.insert(-1, custom)
-
-class Sound:
- playing = False
- current = None
- player = None
-
- def __init__(self, name, imgfile, soundfile, type):
- self.name = name
- self._thumb = Theme.pixbuf(imgfile, THUMB_SIZE)
- self._type = type
-
- if type == JOURNAL:
- l = sorted(glob(os.path.join(Theme.SESSION_PATH, 'sound*')))
- self._soundfile = os.path.join(Theme.SESSION_PATH,
- 'sound.%03d' % (len(l)+1))
- os.rename(soundfile, self._soundfile)
- else:
- self._soundfile = soundfile
-
- def filename(self):
- return self._soundfile
-
- def thumb(self):
- return self._thumb
-
- def change(self):
- out = self
-
- if self._type == CUSTOM:
- out = Theme.choose(
- lambda title, file: Sound(title,
- 'images/sounds/speaker.png', file, JOURNAL))
- if not out:
- return None
-
- Sound.current = self
- if not Sound.playing: return out
- Sound.player.set_state(gst.STATE_NULL)
- if len(out._soundfile) == 0: return out
-
- Sound.player.set_property('uri', 'file://' + Theme.path(out._soundfile))
- Sound.player.set_state(gst.STATE_NULL)
- Sound.player.set_state(gst.STATE_PLAYING)
-
- return out
-
-THEMES = [
- Sound(_('Gobble'), 'images/sounds/speaker.png', 'sounds/gobble.wav',
- PREISTALLED),
- Sound(_('Funk'), 'images/sounds/speaker.png', 'sounds/funk.wav',
- PREISTALLED),
- Sound(_('Giggle'), 'images/sounds/speaker.png', 'sounds/giggle.wav',
- PREISTALLED),
- Sound(_('Jungle'), 'images/sounds/speaker.png', 'sounds/jungle.wav',
- PREISTALLED),
- Sound(_('Mute'), 'images/sounds/mute.png', '',
- PREISTALLED),
- None,
- Sound(_('Custom'), 'images/sounds/custom.png', None,
- CUSTOM)]
-
-Sound.current = THEMES[0]
-
-def play():
- Sound.playing = True
- Sound.current.change()
-
-def stop():
- Sound.playing = False
- Sound.player.set_state(gst.STATE_NULL)
-
-# GSTREAMER STUFF
-
-def _gstmessage_cb(bus, message):
- type = message.type
-
- if type == gst.MESSAGE_EOS:
- # END OF SOUND FILE
- Sound.player.set_state(gst.STATE_NULL)
- Sound.player.set_state(gst.STATE_PLAYING)
- elif type == gst.MESSAGE_ERROR:
- Sound.player.set_state(gst.STATE_NULL)
-
-Sound.player = gst.element_factory_make("playbin", "player")
-fakesink = gst.element_factory_make('fakesink', "my-fakesink")
-Sound.player.set_property("video-sink", fakesink)
-
-bus = Sound.player.get_bus()
-bus.add_signal_watch()
-bus.connect('message', _gstmessage_cb)