0

Alright, so in my code I have a pretty basic music setup:

mainMusic = pygame.mixer.music.load('main_sound.mp3')
pygame.mixer.music.play(-1, 0.0)

then, to stop the music I have:

while True:
    if event.type == KEYUP:
        if event.key == K_ESCAPE:
            pygame.quit()
            sys.exit()
        if event.key == ord('m'):
            if play:
                pygame.mixer.music.stop()
            else:
                pygame.mixer.music.play(-1, 0.0)
            play = not play

but for some reason, when i mute the music, it stutters before stopping, if it stops at all. (at school, on their computers it will sometimes stutter until played again, and then stutter starting up, or sometimes, just continue stuttering)

is there anyway to stop this, or is there just something wrong with the music?

raincloud
  • 21
  • 1
  • 8
  • at home, on my laptop, it usually just stutters then stops, but also seems to stutter and not start when played after being muted. – raincloud Apr 25 '17 at 00:53
  • Isn't there missing something between the `while` and `if`? As in how are you getting `event`? – vallentin Apr 25 '17 at 00:59
  • ok, so actually, the if was outside my get event thing... i feel dumb now. i completely missed that. – raincloud Apr 25 '17 at 01:01

0 Answers0