示例#1
0
def main():
        global thread_finished
#	logger.info('Player started!')
	
	# Basic commands for play the music
#	currentBackup = ""

	# Initialize LCD
	lcd = LCD()
	lcd.clear()
	lcd.begin(16,1)

        # Stop all players
        run_cmd(cmd_stop_all, False)

	# Start radio or backup
#	ledConnection = 2
#	ledCheck = 3

	GPIO.setmode(GPIO.BCM)
#	GPIO.setup(ledConnection, GPIO.OUT)

	# Start the main program in an infinite loop
	while True: 
		lcd.clear()
		lcd.message("ExeaMusicPlayer")
		sleep(2)
		
		lcd.clear()
		lcd.message("Escuchas:\n")
		lcd.message(title)
		sleep(2)
		
		#Check connection of internet
#		GPIO.output(ledConnection, 1)
		if checkInternetConnection():
#			GPIO.output(ledConnection, 0)
			#sleep(0.5)
                        lcd.clear()
                        lcd.message("Estas conectado\na Internet")
                        sleep(3)
		#Show IP info 
		lcd.clear()
		ipaddr = run_cmd(cmd_ip)
		if not ipaddr:
			lcd.message('Sin Internet\n')
		else:
			lcd.message('IP%s' % ( ipaddr ))

		#Show date for 10 seconds
		i = 0
		while i<10:
			lcd.message(datetime.now().strftime('%b %d  %H:%M:%S\n'))
			sleep(1)
			i = i+1
			pass

	thread_finished = True
示例#2
0
def buttons():
    global thread_finished
    buttonShutdown = 11
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(buttonShutdown, GPIO.IN)

    while True:
        if (GPIO.input(buttonShutdown)):
            lcd = LCD()
            lcd.clear()
            lcd.begin(16,1)
            lcd.message("Reiniciando\nSistema...")
            sleep(2)
            lcd.clear()
            reboot()
    	sleep(4)
    thread_finished = True
示例#3
0
def main():
    logger.info('Player started!')
    # Initialize LCD
    lcd = LCD()
    lcd.clear()
    lcd.begin(16,1)
    # Start the main program in an infinite loop
    while True:
        status = run_cmd(cmd_check_device, True)
        status = status[:4]
        lcd.clear()
        lcd.message("ExeaMusicPlayer\n")
        lcd.message( 'Estado: ' + status )
        sleep(2)

        lcd.clear()
        lcd.message("Escuchas:\n")
        lcd.message(title)
        sleep(2)

        #Show Serial
        lcd.clear()
        lcd.message("Serial:\n")
        lcd.message(serial)
        sleep(3)

        #Show IP info
        lcd.clear()
        ipaddr = run_cmd(cmd_ip)

        if not ipaddr:
            lcd.message('Sin Internet\n')
        else:
            lcd.message( ipaddr )

	#Show date for 10 seconds
        i = 0
        while i<10:
            lcd.message(datetime.now().strftime('%b %d  %H:%M:%S\n'))
            sleep(1)
            i = i+1
            pass
    thread_finished = True
def buttons():
	global thread_finished
	
	buttonReboot = 9
	buttonRestart = 10 
	buttonShutdown = 11
	
	GPIO.setmode(GPIO.BCM)

	GPIO.setup(buttonReboot, GPIO.IN)
	GPIO.setup(buttonShutdown, GPIO.IN)
	GPIO.setup(buttonRestart, GPIO.IN)

	while True:

		# if the last reading was low and this one high, print
		if (GPIO.input(buttonReboot)):
			lcd = LCD()
			lcd.clear()
			lcd.begin(16,1)
			lcd.message("Reiniciando\nSistema")
			sleep(3)
			lcd.clear()
			reboot()
			sleep(0.5)
			
			
		if (GPIO.input(buttonShutdown)):
			lcd = LCD()
			lcd.clear()
			lcd.begin(16,1)
			lcd.message("Apagando\nSistema...")
			sleep(3)
			lcd.clear()
			shutdown()
			sleep(0.5)
			

		if (GPIO.input(buttonRestart)):
			lcd = LCD()
			lcd.clear()
			lcd.begin(16,1)
			lcd.message("Reiniciando\nReproductor")
			sleep(3)
			lcd.clear()
			restart()
			sleep(0.5)

	thread_finished = True
def main():
	global thread_finished
	logger.info('Player started!')

	# Read arguments
	if len(sys.argv) >= 3:	
		url = sys.argv[1]
		# Read the title of the streaming
		if len(sys.argv) > 3:
			title = sys.argv[2]
			for x in xrange(3,len(sys.argv)):
				title = title + " " + sys.argv[x]
		else:
			title = sys.argv[2]
	else:
		print "Usage: player.py {url} {title}";
		logger.error("Usage: player.py {url} {title}")
		return

	print "The url of the streaming is:",colored(url, "green")
	print "The name of the radio is:", colored(title, "green")
	logger.info('The url of the streaming is: ' + url)
	logger.info('The name of the radio is: ' + title)

	# Initialize variables
	
	# Basic commands for play the music
	cmd_play_streaming = "mpg123 " + url + " &"
	currentBackup = ""

	# Initialize LCD
	lcd = LCD()
	lcd.clear()
	lcd.begin(16,1)

	# Stop all players
	run_cmd(cmd_stop_all, False)

	# Start radio or backup
	ledConnection = 2
	ledCheck = 3

	GPIO.setmode(GPIO.BCM)
	GPIO.setup(ledConnection, GPIO.OUT)
	GPIO.setup(ledCheck, GPIO.OUT)

	playingRadio = True
	if checkInternetConnection():
		run_cmd(cmd_play_streaming, False)
		logger.info("Playing streamming from " + url)
	else:
		playBackup()
		playingRadio = False

	# Start the main program in an infinite loop

	while 1:
		lcd.clear()
		lcd.message("ExeaMusicPlayer")
		sleep(2)
		
		if playingRadio:
			# Check Internet status
			if checkInternetConnection():
				lcd.clear()
				lcd.message("Escuchas:\n")
				lcd.message(title)
				sleep(2)
				pass
			else:
				# Play backup
				lcd.clear()
				lcd.message("Reproduciendo\nrespaldo")
				sleep(1)
				currentBackup = playBackup()
				lcd.clear()
				lcd.message("Respaldo\n")
				lcd.message(currentBackup)
				sleep(2)
				playingRadio = False
				pass
			pass
		else:
			# Restore streaming radio or show status of "backup"
			if checkInternetConnection():
				run_cmd(cmd_stop_all, False)
				run_cmd(cmd_play_streaming, False)
				logger.info('Playing streamming from ' + url)
				playingRadio = True
				pass
			else:
				lcd.clear()
				lcd.message("Respaldo\n")
				lcd.message(currentBackup)
				sleep(2)
		#Check connection of internet
		GPIO.output(ledConnection, 1)
		if checkInternetConnection():
			GPIO.output(ledConnection, 0)
			sleep(0.5)

		#Check Play the Backup or Stream
		if playingRadio == True:
			GPIO.output(ledCheck, 1)
		else:
			GPIO.output(ledCheck, 0)

		#Show IP info 
		lcd.clear()
		ipaddr = run_cmd(cmd_ip)
		if not ipaddr:
			lcd.message('Sin Internet\n')
		else:
			lcd.message('IP %s' % ( ipaddr ))

		#Show date for 10 seconds
		i = 0
		while i<10:
			lcd.message(datetime.now().strftime('%b %d  %H:%M:%S\n'))
			sleep(1)
			i = i+1
			pass

	thread_finished = True