I want to great a small (local) jukebox without a display. Songs are stored on the SD card and every button is more or less hardwired to one song (always to the song called "1.mp3" on the sd card which could be changed of course) Other then that the functions would be pretty simple: just press button, song plays, press next button song is added to playlist, playlist continous after first song ends.
I now read about Pygame and it seemingly being a good choice for all things music on the Pi. The first issue I read is that it only works when a display screen is attached to the Pi. Is that really the case? And if so are there any good alternatives to Pygame where I dont need a display?
Also on PyGame or an alternative, what would the code rougly look like? Here a try for Pygame: Pretty sure its crappy as it is... first try in Python ^^
import pygame import time import RPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) pygame.mixer.init() playlist = glob.glob('/home/pi/Music/*.mp3') def button_1(channel): if event.type == pygame.USEREVENT: pygame.mixer.music.queue ( playlist.1.mp3() ) def button_2(channel): if event.type == pygame.USEREVENT: pygame.mixer.music.queue ( playlist.2.mp3() ) GPIO.add_event_detect(10,GPIO.RISING,callback=button_1) GPIO.add_event_detect(11,GPIO.RISING,callback=button_2) pygame.mixer.music.load ( playlist ) pygame.mixer.music.play() running = True while running: for event in pygame.event.get(): GPIO.cleanup()