I'm trying to get a .wav file to play in my python script.
If I place the sound in the root folder the sound works.
If I move the file and reference it in the script it doesn't and I'm sure my reference is wrong. I have tried 3 ways, but nothing seems to be working.
Attempt 1:
sounds = os.path.basename ("C:\pager printer\src\pagerprinter\sounds\a.wav") s = pygame.mixer.Sound("sounds")
Attempt 2:
s = pygame.mixer.Sound("C:\pager printer\src\pagerprinter\sounds\a.wav")
Attempt 3:
sounds = os.path.basename("/pagerprinter/sounds/a.wav")
s = pygame.mixer.Sound("sounds")
Attempt 3 script is run in folder src using
c:\pager printer\src>python -m pagerprinter.pagerprinter
If I place sound in
C:\pager printer\src
and run code as
s = pygame.mixer.Sound("a.wav")`
It works, but I wish to make file neat and tidy.
Found it
s = os.path.join('pagerprinter', 'sounds', 'a.wav')
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments