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(**kwargs)

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

filename

Deprecated since version 1.3.0: Use source instead

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.

status

Deprecated since version 1.3.0: Use state instead

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