0

I am looking to play a .wav file using pygame but I can't seem to get it to work. Here is the error I get:

pygame.error: Unable to open file 'Audio Assets\never.wav'

This is the code I use to play the file:

import pygame

pygame.mixer.pre_init()
pygame.mixer.init()
pygame.init()

pygame.mixer.Channel(0).play(pygame.mixer.Sound('Audio Assets\never.wav'), maxtime=1000)

Here is the WAV file itself (Yes it is Logan Paul at the suicide forest because my tiny monkey brain can't come up with a different example):

https://ufile.io/nlxvd

I have alread tried converting it to a .ogg file but that won't work either.

Mihkel
  • 579
  • 4
  • 22
  • \n within the file string is an escape, try adding another backslash before the first one – The4thIceman Dec 05 '18 at 20:42
  • Is it the same with \r ? I have another WAV that starts with an r and wont work either. – Mihkel Dec 06 '18 at 06:30
  • yes. here are the escape characters. https://docs.python.org/2.0/ref/strings.html. You can also get into the habit of using double backslashes in general so you don't have to memorize the escapes – The4thIceman Dec 06 '18 at 11:11
  • Thank you, I mostly use double backslashes in python but the example I saw for pygame.mixer used only one so I just kind of stuck with that. – Mihkel Dec 06 '18 at 11:18

0 Answers0