changeset 3354:3834652ddd53 trunk

branch merge
author Tomasz Mon <desowin@gmail.com>
date Thu, 16 Aug 2007 13:35:25 +0200
parents 1cd5fb04e05b (current diff) b35d905d1a83 (diff)
children 31ecb89e871c
files
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/lap.py	Thu Aug 16 13:34:48 2007 +0200
+++ b/contrib/lap.py	Thu Aug 16 13:35:25 2007 +0200
@@ -41,6 +41,10 @@
 import fnmatch, optparse, os, subprocess
 from dbus import Bus, DBusException
 
+# Support audtool as a fallback but don't depend on it
+try: import subprocess
+except ImportError: pass
+
 # Use readline if available but don't depend on it
 try: import readline
 except ImportError: pass
@@ -70,10 +74,17 @@
 
 def addTrack(path, play=False):
 	try:
+		file_url = 'file://' + path
 		mp = bus.get_object('org.freedesktop.MediaPlayer', '/TrackList')
-		mp.AddTrack('file://' + path, play)
+		mp.AddTrack(file_url, play)
 	except DBusException:
-		print "ERROR: Unable to contact media player."
+		try:
+			if subprocess.call(['audtool','playlist-addurl',file_url]):
+				print "ERROR: audtool fallback returned an error for: %s" % file_url
+			else:
+				os.system('audtool playlist-jump `audtool playlist-length`; audtool playback-play')
+		except OSError:
+			print "ERROR: Unable to call audtool as a fallback for: %s" % file_url
 
 def parseChoice(inString):
 	try: