def is_active(self, dbus_iface): if self.configuration_found: try: mpdclient2.connect(host = self.host, port = self.port, password = self.password) return True except Exception, e: pass
def is_active(self, dbus_iface): if self.configuration_found: try: mpdclient2.connect(host=self.host, port=self.port, password=self.password) return True except Exception, e: pass
def checkForUpdate(self): try: # song change events if self.onSongChanged: playing_song = self.getCurrentFile() if playing_song != self.lastSong: if self.onSongChanged != None: #print 'generate onSongChange' self.onSongChanged(playing_song) self.lastSong = playing_song # elapsed events if self.onElapsed: elapsed = self.getElapsed() if elapsed-self.lastTime > 2 or elapsed-self.lastTime < 0: self.onElapsed(elapsed) self.lastTime = elapsed # play/stop events status = mpdclient2.connect(host = self.host, port = self.port, password = self.password).status().state if self.lastStatus != None and status != self.lastStatus: if status == 'play' and self.onPlay != None: self.onPlay() if self.lastStatus == 'play' and (status == 'pause' or status == 'stop') and self.onStop != None: self.onStop() self.lastStatus = status return True except Exception, e: print e return False
def getElapsed(self): try: time = mpdclient2.connect(host = self.host, port = self.port, password = self.password).status().time elapsed = float(time.replace(":", ".")) return elapsed except Exception, e: return 0.0
def is_playing(self): try: return mpdclient2.connect( host=self.host, port=self.port, password=self.password).status().state == "play" except Exception, e: print e
def get_album(self): try: return mpdclient2.connect( host=self.host, port=self.port, password=self.password).currentsong().album except Exception, e: print e
def getCurrentFile(self): try: song = mpdclient2.connect( host=self.host, port=self.port, password=self.password).currentsong().file return self.music_dir + song except Exception, e: print e
def getElapsed(self): try: time = mpdclient2.connect(host=self.host, port=self.port, password=self.password).status().time elapsed = float(time.replace(":", ".")) return elapsed except Exception, e: return 0.0
def checkForUpdate(self): try: # song change events if self.onSongChanged: playing_song = self.getCurrentFile() if playing_song != self.lastSong: if self.onSongChanged != None: #print 'generate onSongChange' self.onSongChanged(playing_song) self.lastSong = playing_song # elapsed events if self.onElapsed: elapsed = self.getElapsed() if elapsed - self.lastTime > 2 or elapsed - self.lastTime < 0: self.onElapsed(elapsed) self.lastTime = elapsed # play/stop events status = mpdclient2.connect(host=self.host, port=self.port, password=self.password).status().state if self.lastStatus != None and status != self.lastStatus: if status == 'play' and self.onPlay != None: self.onPlay() if self.lastStatus == 'play' and ( status == 'pause' or status == 'stop') and self.onStop != None: self.onStop() self.lastStatus = status return True except Exception, e: print e return False
def get_title(self): try: return mpdclient2.connect(host = self.host, port = self.port, password = self.password).currentsong().title except Exception, e: print e
def getCurrentFile(self): try: song = mpdclient2.connect(host = self.host, port = self.port, password = self.password).currentsong().file return self.music_dir+song except Exception, e: print e
def is_playing(self): try: return mpdclient2.connect(host = self.host, port = self.port, password = self.password).status().state == "play" except Exception, e: print e