Reputation: 188
Here's my code.
soundObj = pygame.mixer.Sound("burr.wav")
soundObj.play()
time.sleep(7) # 7 seconds for sound to play
soundObj.stop()
This current code allows me to play the sound for just 7 seconds even if it is 8 seconds long. Also, if the sound file is 4 seconds long, it will still sleep for 7 seconds. This is an issue.
I want the audio file to play for it's entire duration. No more, no less.
So I figure there are two ways of doing this.
I could have some kind of flag that is set the moment the file finishes playing. How do I do this?
Or, if I could somehow procure the duration of the sound file, I could replace time.sleep with time.sleep(duration). That would also solve my problem (I hope!).
So what do you think folks?
Upvotes: 0
Views: 2159