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 16:11:38 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-12-29 16:11:38 (GMT)
commitf59b2031db0dde0291377243604551278024dd16 (patch)
tree90848f834b80aa2c7ba4132dd2daf068b46427d8 /utils
parent691d305b04ec884d302be78656d4d1695510f220 (diff)
generalize play_audio for more systemsv3
Diffstat (limited to 'utils')
-rw-r--r--utils/play_audio.py35
1 files changed, 29 insertions, 6 deletions
diff --git a/utils/play_audio.py b/utils/play_audio.py
index 2ed445b..9a6eedf 100644
--- a/utils/play_audio.py
+++ b/utils/play_audio.py
@@ -22,13 +22,36 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
-
+import os
import subprocess
-def play_audio_from_file(parent, file_path):
+import logging
+_logger = logging.getLogger('iknowmyabcs-activity')
+
+
+GST_PATHS = ['/usr/bin/gst-launch', '/bin/gst-launch',
+ '/usr/local/bin/gst-launch',
+ '/usr/bin/gst-launch-1.0', '/bin/gst-launch-1.0',
+ '/usr/local/bin/gst-launch-1.0',
+ '/usr/bin/gst-launch-0.10', '/bin/gst-launch-0.10',
+ '/usr/local/bin/gst-launch-0.10']
+
+
+def play_audio_from_file(file_path):
""" Audio media """
- command_line = ['gst-launch', 'filesrc', 'location=' + file_path,
- '! oggdemux', '! vorbisdec', '! audioconvert',
- '! alsasink']
- subprocess.call(command_line)
+ 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 not hasattr(play_audio_from_file, 'gst_launch'):
+ _logger.debug('gst-launch not found')
+ return
+
+ command_line = [play_audio_from_file.gst_launch, 'filesrc',
+ 'location=' + file_path, '! oggdemux', '! vorbisdec',
+ '! audioconvert', '! alsasink']
+ subprocess.check_output(command_line)