0

I was trying to play a song with pygame, but instead of giving the path directly i wanted to give a variable that stores the path to the pygame.mixer.music.load() method. I used to run this, and it worked.

b = "C:\\Users\\Enny\\Music\\I can tell.mp3"


def pMusic():
    import pygame
    pygame.mixer.init()


    pygame.mixer.music.load(b)
    pygame.mixer.music.play()

a = input("")

if a == "play":
    pMusic()

But now every time i try, i get this error

 Traceback (most recent call last):
  File "test.py", line 17, in <module>
    pMusic()
  File "test.py", line 11, in pMusic
    pygame.mixer.music.load(b)
pygame.error
ll0
  • 13
  • 2
  • Is there more info or is that the entire exception? – jarmod Oct 06 '20 at 18:59
  • @jarmod nope, that's it, i thought that it was a problem with the pygame library, so i reinstalled it but didn't work – ll0 Oct 06 '20 at 19:26
  • Copy a valid MP3 file to sample.mp3 in the same directory in which you run the pygame app, then set `b = "sample.mp3"` and re-test. Try to take potential path issues and escaped folder names out of the equation. – jarmod Oct 06 '20 at 19:35
  • @jarmod still the same – ll0 Oct 06 '20 at 20:04
  • Any obvious differences between when this used to work and now? Also, the docs say that MP3 support is limited and you should consider OGG instead. – jarmod Oct 06 '20 at 20:14
  • yeah, i'll try using ogg files, but it's weird, i don't remember making any changes – ll0 Oct 06 '20 at 20:37

0 Answers0