[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37846] trunk/blender/doc/python_api/ examples/aud.py: basic sound playback example for audspace module
Dalai Felinto
dfelinto at gmail.com
Mon Jun 27 07:12:04 CEST 2011
Revision: 37846
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37846
Author: dfelinto
Date: 2011-06-27 05:12:03 +0000 (Mon, 27 Jun 2011)
Log Message:
-----------
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)
Added Paths:
-----------
trunk/blender/doc/python_api/examples/aud.py
Added: trunk/blender/doc/python_api/examples/aud.py
===================================================================
--- trunk/blender/doc/python_api/examples/aud.py (rev 0)
+++ trunk/blender/doc/python_api/examples/aud.py 2011-06-27 05:12:03 UTC (rev 37846)
@@ -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()
More information about the Bf-blender-cvs
mailing list