English 中文(简体)
Pygame - Mixer channels
  • 时间:2024-12-22

Pygame - Mixer Channels


Previous Page Next Page  

The Sound object can be played on a specific channel instead of the default channel automatically chosen. First create a channel object using the following command −


pygame.mixer.Channel(id)

Following functions are defined in the mixer.channel class −

play(Sound, loops=0, maxtime=0, fade_ms=0) This will begin playback of a Sound on a specific Channel.
stop() Stop sound playback on a channel. After playback is stopped the channel becomes available for new Sounds to play on it
pause() Temporarily stop the playback of sound on a channel.
unpause() Resume the playback on a paused channel.
set_volume(value) Set the volume (loudness) of a playing sound. The value argument is between 0.0 and 1.0.
queue(Sound) When a Sound is queued on a Channel, it will begin playing immediately after the current Sound is finished.
Advertisements