The following works as expected:
pygame.mixer.init(frequency=22050, size=8, channels=2, buffer=2)
pygame.init()
pygame.mixer.music.load('audio/beep.xm')
loop_event = pygame.USEREVENT + 1
pygame.mixer.music.set_endevent(loop_event)
pygame.mixer.music.play(loops=-1, start=00)
However this:
pygame.mixer.init(frequency=22050, size=8, channels=2, buffer=2)
pygame.init()
beep = pygame.mixer.Sound('audio/beep.xm')
beep.play()
Gives the following error:
pygame.error: Unable to open file 'audio/beep.xm'
I can't see any related issue to this as I am sure I am initialising pygame.mixer correctly and as it works as music it doesn't appear to be an issue with the fule itself. I have tried using the full path and variations of the path, all gave me the same error.
The Pygame Docs for pygame.mixer.Sound
state:
The Sound can be loaded from an OGG audio file or from an uncompressed WAV
xm
audio files are not supported by pygame.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.