Table Of Contents
Audio¶
Load an audio sound and play it with:
from kivy.core.audio import SoundLoader
sound = SoundLoader.load('mytest.wav')
if sound:
print "Sound found at %s" % sound.source
print "Sound is %.3f seconds" % sound.length
sound.play()
You should not use directly the sound class yourself. The result will use the best sound provider for reading the file, so you might have a different Sound class depending the file.
Note
Recording audio is not supported.
- class kivy.core.audio.Sound¶
Bases: kivy.event.EventDispatcher
Represent a sound to play. This class is abstract, and cannot be used directly.
Use SoundLoader to load a sound !
Events : - on_play : None
Fired when the sound is played
- on_stop : None
Fired when the sound is stopped
- get_pos()¶
get the current position of the audio file. returns 0 if not playing
New in version 1.4.1.
- length¶
Get length of the sound (in seconds)
- load()¶
Load the file into memory
- play()¶
Play the file
- seek(position)¶
Seek to the <position> (in seconds)
- source¶
Filename / source of your image.
New in version 1.3.0.
source a StringProperty, default to None, read-only. Use the SoundLoader.load() for loading audio.
- state¶
State of the sound, one of ‘stop’ or ‘play’
New in version 1.3.0.
state is an OptionProperty, read-only.
- stop()¶
Stop playback
- unload()¶
Unload the file from memory
- volume¶
Volume, in the range 0-1. 1 mean full volume, 0 mean mute.
New in version 1.3.0.
volume is a NumericProperty, default to 1.
- class kivy.core.audio.SoundLoader¶
Load a sound, with usage of the best loader for a given filename.
- static load(filename)¶
Load a sound, and return a Sound() instance
- static register(classobj)¶
Register a new class to load sound