Main > Audio/Jukebox/MP3 Forum
FLAC routines similar to Pygame
rtp_burnsville:
Hi,
Does anyone happen to know of some FLAC routines for playing FLAC files using Python?
I am writing a Jukebox program using Python and it currently uses Pygame for MP3 files. My music library is FLAC files so would like to directly access those for higher quality music playback. Have searched for days and not finding much of anything useful to get me started.
Thanks
10yard:
--- Quote from: rtp_burnsville on September 14, 2021, 12:14:33 pm ---Hi,
Does anyone happen to know of some FLAC routines for playing FLAC files using Python?
I am writing a Jukebox program using Python and it currently uses Pygame for MP3 files. My music library is FLAC files so would like to directly access those for higher quality music playback. Have searched for days and not finding much of anything useful to get me started.
Thanks
--- End quote ---
Direct play of FLAC is supported in recent versions of pygame. I have tested this very simple script with pygame 2.0.12 successfully. Run the script and press the "any key" to play the FLAC file.
--- Code: ---import pygame
pygame.init()
pygame.display.set_mode((640, 480))
pygame.mixer.music.load('foo.flac')
while True:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
pygame.mixer.music.play()
pygame.display.update()
--- End code ---
You should update your pygame if you can. Latest version is 2.0.1.
rtp_burnsville:
Thank you for the information on a Pygame update...... This would be great as I could use most of the current code I have. I'll check it out.
rtp_burnsville:
Have spent several hours trying to install pygame 2.0.x on my Raspberry Pi but no luck..... Some parts appear to install but the mixer portion appears not to work. Any suggestions would be much appreciated.
The May update of the OS still includes a very old version of pygame 1.9.x
Thanks
10yard:
--- Quote from: rtp_burnsville on September 28, 2021, 12:02:43 pm ---Have spent several hours trying to install pygame 2.0.x on my Raspberry Pi but no luck..... Some parts appear to install but the mixer portion appears not to work. Any suggestions would be much appreciated.
The May update of the OS still includes a very old version of pygame 1.9.x
Thanks
--- End quote ---
There are some dependencies for pygame (including mixer) which may or may not be installed depending on your OS version.
You can install them as follows.
--- Code: ---sudo apt-get install libsdl2-mixer-2.0-0 libsdl2-image-2.0-0 libsdl2-2.0-0 libsdl2-ttf-2.0-0
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version