mercredi 30 janvier 2019

Check If A PyGame Mixer Channel Is Playing A Sound

I am looking for a way to see if a pygame.mixer.Channel is currently playing a sound. So for example do something only after the sound played in a specific channel has finished. Here is my current code to just play the sound:

import pygame

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

pygame.mixer.Channel(0).play(pygame.mixer.Sound('coolsound.wav'), maxtime=2000)

I was thinking an if statement something like this:

if pygame.mixer.Channel(0) = playing a sound:
    print("playing a sound")
else:
    print("not playing")

Obviously this wouldn't work, just to give you an idea of what I am looking for. Thanks!

Aucun commentaire:

Enregistrer un commentaire