There is a possibility to use aud module to play the sound file. It is easy to load the file from disk. But how to load the file from the resource packed into the blend file?
In Blender i can do something like that
| Code: |
import aud
import bpy
device = aud.device()
factory = bpy.data.sounds['39068__alienbomb_.000'].factory
GameLogic.snd_4 = aud.Factory.buffer(factory)
|
But in Game Engine the module bpy is not available.
So the question is how to create the factory for file stored as packed resource in Game Engine. Any suggestions?[/code]
The easiest sollution (thanks to Dalai) is to create actuators with sounds and to get the factory from the actuators, like this:
| Code: |
co = GameLogic.getCurrentController()
act = co.actuators['sound_1']
import aud
device = aud.device()
factory = act.sound
snd_handle = device.play(factory)
|