def refresh(self): try: # song change events if self.onSongChanged != None: playing_song = self.playerAPI.get_uri() if playing_song != "": if playing_song != self.lastSong: self.onSongChanged(utils.get_local_path_from_uri(playing_song)) self.lastSong = playing_song # elapsed events if self.onElapsed: elapsed = self.getElapsed() if elapsed-self.lastTime not in range (0,3): #print str(elapsed) +' '+str(self.lastTime) self.onElapsed(elapsed) self.lastTime = elapsed # play/stop events state = "play" if self.is_playing() else "stop" if (state != self.lastState): if state == "play" and self.onPlay != None: self.onPlay() if state == "stop" and self.onStop != None: self.onStop() self.lastState = state return True except Exception, e: print e return False
def getCurrentFile(self): uri = self.playerAPI.getPlayingUri() if uri.startswith("http"): self.switch_to_radio_mode() print "use title: %s" % self.get_title() return self.get_title() return utils.get_local_path_from_uri(uri)
def songChangedSignal(self, uri): print "RHYTHMBOX SONG CHANGED" if uri.startswith("http") and self.getElapsed() > 10: self.switch_to_radio_mode() if uri: self.onSongChanged(utils.get_local_path_from_uri(uri)) self.lastTime = None
def getCurrentFromMetadata(self, metadata): try: metadata = self.playerAPI.GetMetadata() except: print "Error in getting player metadata" return None if metadata.has_key('location'): uri = metadata['location'] elif metadata.has_key('URI'): uri = metadata['URI'] # audacious want be unique else: print "Can't get current song info from MPRIS API" return return utils.get_local_path_from_uri(uri)
def getCurrentFile(self): uri = self.playerAPI.GetCurrentUri() return utils.get_local_path_from_uri(uri)