Audio: Load and play sound

_REF

Audio: Load and play sound

class pymt.core.audio.Sound(**kwargs)

Bases: pymt.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

Get/set the filename/uri of the sound

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)

status

Get the status of the sound (stop, play)

stop()

Stop playback

unload()

Unload the file from memory

volume

Get/set the volume of the sound

class pymt.core.audio.SoundLoader

Load a sound, with usage of the best loader for a given filename. If you want to load an audio file

sound = SoundLoader.load(filename='test.wav')
if not sound:
    # unable to load this sound ?
    pass
else:
    # sound loaded, let's play!
    sound.play()
static load(filename)

Load a sound, and return a Sound() instance

static register(classobj)

Register a new class to load sound

Previous topic

Core: providers for image, text, video, audio, camera...

Next topic

Camera: Backend for acquiring camera image

This Page