im trying to use winsound to play wav file ONCE

120 views Asked by At

heres my code

import winsound
winsound.PlaySound('filename.wav',winsound.SND_LOOP)

i want to play it ONCE not in a loop. i tried removing

SND_LOOP

but it didnt work

2

There are 2 answers

0
med benzekri On

i don't have windows os to test it but according to the docs try this :

import winsound
winsound.PlaySound('filename.wav',winsound.SND_FILENAME)
0
Michalor On

Just don't use the winsound.SND_LOOP flag. Use 0 or winsound.SND_ASYNC flag instead.

import winsound
winsound.PlaySound('filename.wav',0)

Documentation