예제 #1
0
	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
예제 #2
0
 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
예제 #3
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
예제 #4
0
	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
예제 #5
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
예제 #6
0
 def get_album(self):
     try:
         return mpdclient2.connect(
             host=self.host, port=self.port,
             password=self.password).currentsong().album
     except Exception, e:
         print e
예제 #7
0
 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
예제 #8
0
 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
예제 #9
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
예제 #10
0
	def get_title(self):
		try:
			return mpdclient2.connect(host = self.host, port = self.port, password = self.password).currentsong().title
		except Exception, e:
			print e
예제 #11
0
	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
예제 #12
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