diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2011-06-27 09:12:03 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2011-06-27 09:12:03 +0400 |
commit | 9dbec62bc01ac0977d41be6e7e9b866450b92ebf (patch) | |
tree | be7ce719d3c0c35f2a76438ccbf7e82b023f4a04 | |
parent | ae49f6deb0e4a41ea0b50603472a7b2ee7b870e3 (diff) |
basic sound playback example for audspace module
(I'm on windows at the moment so I can't test it. Hopefully it should be fine)
-rw-r--r-- | doc/python_api/examples/aud.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/doc/python_api/examples/aud.py b/doc/python_api/examples/aud.py new file mode 100644 index 00000000000..a7f0bf9fbab --- /dev/null +++ b/doc/python_api/examples/aud.py @@ -0,0 +1,21 @@ +""" +Basic Sound Playback +++++++++++++++++++++++ +This script shows how to use the classes: :class:`Device`, :class:`Factory` and +:class:`Handle`. +""" +import aud + +device = aud.device() +# load sound file (it can be a video file with audio) +factory = aud.Factory('music.ogg') + +# play the audio, this return a handle to control play/pause +handle = device.play(sound) +# if the audio is not too big and will be used often you can buffer it +factory_buffered = aud.Factory.buffer(sound) +handle_buffered = device.play(buffered) + +# stop the sounds (otherwise they play until their ends) +handle.stop() +handle_buffered.stop() |