0

So I am working on a board game and I want to play background music.

I import the mixer library from pygame like so:

from pygame import mixer

I then initiate the mixer:

mixer.init()

Then I load my music file and play it:

mixer.music.load('bgmus.ogg')
mixer.music.set_volume('0.5')
mixer.music.play()

When I run my game, I get this error:

Traceback (most recent call last):

File "boardgame.py", line 15, in module

mixer.init()

pygame.error: No such audio device

I'm on Windows, using codio.com as my compiler and was wondering why this error is occurring.

  • It looks like you're running the code on a server somewhere, which likely has no way of connecting to your speakers, or any speakers for that matter. – Danielle M. Mar 10 '22 at 23:27
  • Ok, so what I'm getting from this is that I can't play any audio whatsoever because of the way codio works. So I'll just have to roll with no audio. – Linkkeeper2 Mar 10 '22 at 23:31
  • if you want the code to have access to your speakers, you'll need to ru it on your computer. You can install python directly, or look into something like jupyter notebooks . – Danielle M. Mar 10 '22 at 23:34

0 Answers0