Home | Trees | Indices | Help |
|
---|
|
1 # This program is free software: you can redistribute it and/or modify 2 # it under the terms of the GNU General Public License as published by 3 # the Free Software Foundation, either version 3 of the License, or 4 # (at your option) any later version. 5 # 6 # This program is distributed in the hope that it will be useful, 7 # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 # GNU General Public License for more details. 10 # 11 # You should have received a copy of the GNU General Public License 12 # along with this program. If not, see <http://www.gnu.org/licenses/>. 13 14 # Kaffeine API (c) Whise (Helder Fraga) 2008 <helder.fraga@hotmail.com> 15 16 17 import os 18 import string 19 import gobject 20 from GenericPlayer import GenericAPI 21 import commands 2224 __name__ = 'Kaffeine API' 25 __version__ = '0.0' 26 __author__ = 'Whise (Helder Fraga)' 27 __desc__ = 'Kaffeine API to a Music Player' 28 29 playerAPI = None 30 31 __timeout = None 32 __interval = 2 33 34 callbackFn = None 35 __curplaying = None 36 37 41 42 # Check if the player is active : Returns Boolean 43 # A handle to the dbus interface is passed in : doesn't need to be used 44 # if there are other ways of checking this (like dcop in amarok)11646 proc = os.popen("""ps axo "%p,%a" | grep "kaffeine" | grep -v grep|cut -d',' -f1""").read() 47 procs = proc.split('\n') 48 if len(procs) > 1: 49 return True 50 else: 51 return False54 55 # The following return Strings57 return commands.getoutput('dcop kaffeine KaffeineIface title')5860 return commands.getoutput('dcop kaffeine KaffeineIface album')6163 return commands.getoutput('dcop kaffeine KaffeineIface artist')64 6567 t = commands.getoutput('dcop kaffeine KaffeineIface getFileName') 68 t = t.split('/') 69 basePath = '' 70 for l in t: 71 if l.find('.') == -1: 72 basePath = basePath + l +'/' 73 74 names = ['Album', 'Cover', 'Folde'] 75 for x in os.listdir(basePath): 76 if os.path.splitext(x)[1] in [".jpg", ".png"] and (x.capitalize()[:5] in names): 77 coverFile = basePath + x 78 return coverFile 79 80 return ''81 #path 82 83 # Returns Boolean85 return commands.getoutput('dcop kaffeine KaffeineIface isPlaying')86 87 # The following do not return any values89 if self.is_playing(): 90 os.system('dcop kaffeine KaffeineIface pause &') 91 else: 92 os.system('dcop kaffeine KaffeineIface play &')95 98100 self.callback_fn = fn 101 # Could not find a callback signal for Listen, so just calling after some time interval 102 if self.__timeout: 103 gobject.source_remove(self.__timeout) 104 self.__timeout = gobject.timeout_add(self.__interval * 1000, self.info_changed)105 #self.playerAPI.connect_to_signal("playingUriChanged", self.info_changed) 106108 # Only call the callback function if Data has changed 109 if self.__curplaying != commands.getoutput('dcop kaffeine KaffeineIface title'): 110 self.__curplaying = commands.getoutput('dcop kaffeine KaffeineIface title') 111 self.callback_fn() 112 113 if self.__timeout: 114 gobject.source_remove(self.__timeout) 115 self.__timeout = gobject.timeout_add(self.__interval * 1000, self.info_changed)
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Jan 4 16:58:28 2012 | http://epydoc.sourceforge.net |