I code on Ubuntu 20.04LTS with python 3.8.2 and in my game, I want to put music, so I use this:
pygame.mixer.init()
music = pygame.mixer.Sound(os.path.join(current_path,'something.mp3'))
music.play()
But I receive this error:
pygame.mixer.init()
pygame.error: No available audio device
What I have to do?
A common problem is selecting the right sound device, if more than one i present.
to list devices:
cat /proc/asound/cards
It could look like this:
0 [CUBE ]: USB-Audio - Audiotrak ProDigy CUBE GYROCOM C&C Co., LTD Audiotrak ProDigy CUBE at usb-0000:04:00.0-2, full speed
1 [IM ]: USB-Audio - VF0530 Live! Cam Chat IM Creative Labs VF0530 Live! Cam Chat IM at usb-0000:04:00.0-1, high speed
2 [HDMI ]: HDA-Intel - HDA ATI HDMI HDA ATI HDMI at 0xf7e60000 irq 45
Then you must edit the ~/.asoundrc to use the right device. If you want to use device 0, set that value for pcm card:
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
Also make sure the following libs are installed and configured:
sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
sudo sdl-config --cflags --libs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With