I am new to python and have been trying to get it to play an mp3.
I tried the code below
import pygame, sys, time
from pygame.locals import *
pygame.init()
DISPLAYSURF = pygame.display.set_mode((400,300))
pygame.display.set_caption('My MP3')
pygame.mixer.init()
pygame.mixer.music.load('Songbird.mp3')
pygame.mixer.music.set_volume(0.9)
pygame.mixer.music.play(0,0.0)
while True:
time.sleep(1)
pygame.display.set_caption('My MP3')
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if pygame.mixer.music.get_busy():
pygame.display.set_caption('Busy')
pygame.display.update()
This works fine on my windows machine. On the Pi it runs telling me it is busy for the right length of time for the mp3, but I cannot seem to hear anything from the HDMI output or the audio out.
I can type in the terminal - mpg123 <filename> - and this plays OK through the HDMI
How do I get python to select the HDMI output?