Ejemplo n.º 1
0
def send_mpd(id):
	global serial
	global mpc
	song = MPC.song()
	song_status = MPC.title_status()
	status = MPC.mpd_status()
	if(song != mpc["song"] or id == -2):
		mpc["song"] = song
		if(id == 0 or id < 0):
			serial_write("mpd 0 "+ mpc["song"] + " \r")
	if(song_status != mpc["song_status"] or id == -2):
		mpc["song_status"] = song_status
		if(id == 1 or id < 0):
			serial_write("mpd 1 "+ mpc["song_status"]["title"] + " \r")
	if(status != mpc["status"] or id == -2):
		if(id == 2 or id < 0):
			mpc["status"] = status
			serial_write("mpd 2 V: " + mpc["status"]["volume"] + "%  RE: " + mpc["status"]["repeat"] +"  RE: " + mpc["status"]["random"] +"\r")
Ejemplo n.º 2
0
def thread_mpc():
	global serial
	global mpc
	old_song = ""
	old_song_status = ""
	old_status = {}
	while 1:
		try:
			time.sleep(1)
			song = MPC.song()
			song_status = MPC.title_status()
			status = MPC.mpd_status()
			if(song != old_song):
				old_song = song
				serial_write("mpd 0 "+ old_song[:23] + " \r")
			if(song_status != old_song_status):
				old_song_status = song_status
				serial_write("mpd 1 "+ old_song_status + " \r")
			if(status != old_status):
				old_status = status
				serial_write("mpd 2 " + old_status +"\r")
		except:
			print "thread_mpc: " + str(sys.exc_info())