Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorWalter 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)
commit4bb021623c85db7d09f3bcbfb30fcdbaf8133a5b (patch)
treebe5145aab3ab40563e5f16ddb8ceb65804692c99 /utils
parentc70d113ece298c8e649021285419e27084d19e0f (diff)
don't need to pass page instance; save gst_launch as a function attribute
Diffstat (limited to 'utils')
-rw-r--r--utils/play_audio.py23
1 files changed, 12 insertions, 11 deletions
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):