Home | Trees | Indices | Help |
|
---|
|
1 # This application is released under the GNU General Public License 2 # v3 (or, at your option, any later version). You can find the full 3 # text of the license under http://www.gnu.org/licenses/gpl.txt. 4 # By using, editing and/or distributing this software you agree to 5 # the terms and conditions of this license. 6 # Thank you for using free software! 7 8 # Amarok API by Whise and vrunner 9 10 import os 11 import string 12 import gobject 13 from GenericPlayer import GenericAPI 14 import commands 1517 __name__ = 'Amarok API' 18 __version__ = '0.0' 19 __author__ = 'Whise and vrunner' 20 __desc__ = 'Amarok API to a Music Player' 21 22 playerAPI = None 23 24 __timeout = None 25 __interval = 2 26 27 callbackFn = None 28 __curplaying = None 29 30 34 35 # Check if the player is active : Returns Boolean 36 # A handle to the dbus interface is passed in : doesn't need to be used 37 # if there are other ways of checking this (like dcop in amarok)10839 proc = os.popen("""ps axo "%p,%a" | grep "amarokapp" | grep -v grep|cut -d',' -f1""").read() 40 procs = proc.split('\n') 41 if len(procs) > 1: 42 return True 43 else: 44 return False47 48 # The following return Strings50 return commands.getoutput('dcop amarok player title')5153 return commands.getoutput('dcop amarok player album')5456 return commands.getoutput('dcop amarok player artist')57 5860 path = commands.getoutput('dcop amarok player coverImage') 61 if path.find('130@nocover.png') != -1: 62 t = commands.getoutput('dcop amarok player path') 63 t = t.split('/') 64 basePath = '' 65 for l in t: 66 if l.find('.') == -1: 67 basePath = basePath + l +'/' 68 69 names = ['Album', 'Cover', 'Folde'] 70 for x in os.listdir(basePath): 71 if os.path.splitext(x)[1] in [".jpg", ".png"] and (x.capitalize()[:5] in names): 72 coverFile = basePath + x 73 return coverFile 74 75 return ''76 77 # Returns Boolean79 return commands.getoutput('dcop amarok player isPlaying')80 81 # The following do not return any values 84 87 9092 self.callback_fn = fn 93 # Could not find a callback signal for Listen, so just calling after some time interval 94 if self.__timeout: 95 gobject.source_remove(self.__timeout) 96 self.__timeout = gobject.timeout_add(self.__interval * 1000, self.info_changed)97 #self.playerAPI.connect_to_signal("playingUriChanged", self.info_changed) 98100 # Only call the callback function if Data has changed 101 if self.__curplaying != commands.getoutput('dcop amarok player nowPlaying'): 102 self.__curplaying = commands.getoutput('dcop amarok player nowPlaying') 103 self.callback_fn() 104 105 if self.__timeout: 106 gobject.source_remove(self.__timeout) 107 self.__timeout = gobject.timeout_add(self.__interval * 1000, self.info_changed)
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Wed Jun 4 18:52:59 2008 | http://epydoc.sourceforge.net |