diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-12-29 15:48:50 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-12-29 15:48:50 (GMT) |
commit | 4bb021623c85db7d09f3bcbfb30fcdbaf8133a5b (patch) | |
tree | be5145aab3ab40563e5f16ddb8ceb65804692c99 | |
parent | c70d113ece298c8e649021285419e27084d19e0f (diff) |
don't need to pass page instance; save gst_launch as a function attribute
-rw-r--r-- | page.py | 12 | ||||
-rw-r--r-- | utils/play_audio.py | 23 |
2 files changed, 18 insertions, 17 deletions
@@ -223,11 +223,11 @@ class Page(): def _play_target_sound(self): if self._activity.mode == 'letter': - play_audio_from_file(self, os.path.join( + play_audio_from_file(os.path.join( self._sounds_path, self._media_data[self.target][1])) else: - play_audio_from_file(self, os.path.join( + play_audio_from_file(os.path.join( self._sounds_path, self._media_data[self.target][0])) self.timeout = None @@ -258,20 +258,20 @@ class Page(): if self._activity.mode == 'letter': if spr in self._cards: - play_audio_from_file(self, os.path.join( + play_audio_from_file(os.path.join( self._sounds_path, self._media_data[self.current_card][1])) return - play_audio_from_file(self, os.path.join( + play_audio_from_file(os.path.join( self._sounds_path, self._media_data[self.current_card][0])) else: if spr in self._pictures: - play_audio_from_file(self, os.path.join( + play_audio_from_file(os.path.join( self._sounds_path, self._media_data[self.current_card][0])) return - play_audio_from_file(self, os.path.join( + play_audio_from_file(os.path.join( self._sounds_path, self._media_data[self.current_card][1])) diff --git a/utils/play_audio.py b/utils/play_audio.py index 124fae6..c06a663 100644 --- a/utils/play_audio.py +++ b/utils/play_audio.py @@ -37,23 +37,24 @@ GST_PATHS = ['/usr/bin/gst-launch', '/bin/gst-launch', '/usr/local/bin/gst-launch-0.10'] -def play_audio_from_file(parent, file_path): +def play_audio_from_file(file_path): """ Audio media """ - gstlaunch = None - for path in GST_PATHS: - if os.path.exists(path): - gstlaunch = path - break + if not hasattr(play_audio_from_file, 'gst_launch'): + for path in GST_PATHS: + if os.path.exists(path): + play_audio_from_file.gst_launch = path + _logger.debug(path) + break - if gstlaunch is None: + if not hasattr(play_audio_from_file, 'gst_launch'): _logger.debug('gst-launch not found') return - command_line = [gstlaunch, 'filesrc', 'location=' + file_path, - '! oggdemux', '! vorbisdec', '! audioconvert', - '! alsasink'] - check_output(command_line, 'unable to play audio %s' % (file_path)) + command_line = [play_audio_from_file.gst_launch, 'filesrc', + 'location=' + file_path, '! oggdemux', '! vorbisdec', + '! audioconvert', '! alsasink'] + check_output(command_line, 'unable to play audio file %s' % (file_path)) def check_output(command, warning): |