The NEW Build Your Own Arcade Controls

Main => Audio/Jukebox/MP3 Forum => Topic started by: rtp_burnsville on September 14, 2021, 12:14:33 pm

Title: FLAC routines similar to Pygame
Post by: 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
Title: Re: FLAC routines similar to Pygame
Post by: 10yard on September 14, 2021, 06:21:28 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

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: [Select]
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()

You should update your pygame if you can.  Latest version is  2.0.1.

Title: Re: FLAC routines similar to Pygame
Post by: rtp_burnsville on September 15, 2021, 11:58:59 am
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.

Title: Re: FLAC routines similar to Pygame
Post by: 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
Title: Re: FLAC routines similar to Pygame
Post by: 10yard on September 28, 2021, 03:37:59 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
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: [Select]
sudo apt-get install libsdl2-mixer-2.0-0 libsdl2-image-2.0-0 libsdl2-2.0-0 libsdl2-ttf-2.0-0

Title: Re: FLAC routines similar to Pygame
Post by: rtp_burnsville on October 05, 2021, 11:33:28 am
Thanks, I'll give it a try...