Class Sound

This class represents a sound that can be played. A sound is a WAV file that can be played on command via the method play. While some platforms may support MP3s, we can only guarantee that WAVs work on all platforms. In order for Kivy to find a WAV file, you should put it in the Sounds directory. Sounds in that folder can be referenced directly by name.

When a sound is played, it cannot be played again until it finishes, or is stopped. This means that if you want multiple, simultaneous sound effects from the same WAV file.you will need to create multiple Sound objects.

Constructor

Sound(source)

Constructor: Loads a new sound from a file.

Parameter:source – The string providing the name of a sound file

Precondition: source is the name of a valid sound file

Attributes

volume

The current sound volume.

1 means full volume, 0 means mute. The default value is 1.

Invariant: Must be a float in the range 0..1.

source

The source file for this sound.

Immutable: This value cannot be changed after the sound is loaded.

Invariant: Must be a nonempty string.

Methods

play()

Plays this sound.

The sound will play until completion, or interrupted by another sound