Search code examples
audiopygamevolume

Sound Questions in Pygame


  1. How can I set a sound's volume?

  2. Is it possible to play two sounds at once?

  3. Can I know if the music is over using 'if~'?


Solution

    1. Pass a value between 0 and 1 to the set_volume method of the sound, e.g.: sound.set_volume(0.5).

    2. Just call the play methods of the sounds successively.

      sound1.play()
      sound2.play()
      

      The default number of channels for sound playback is 8, but it can be changed with pygame.mixer.set_num_channels.

    3. pygame.mixer.music.get_busy