Mercurial > fife-parpg
annotate demos/shooter/scripts/soundmanager.py @ 481:1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 28 Apr 2010 21:33:11 +0000 |
parents | 85fa5fa486a8 |
children | 82d44c471959 |
rev | line source |
---|---|
480
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # #################################################################### |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 # Copyright (C) 2005-2009 by the FIFE team |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # http://www.fifengine.de |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # This file is part of FIFE. |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # FIFE is free software; you can redistribute it and/or |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # modify it under the terms of the GNU Lesser General Public |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # License as published by the Free Software Foundation; either |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # version 2.1 of the License, or (at your option) any later version. |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # This library is distributed in the hope that it will be useful, |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # Lesser General Public License for more details. |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Lesser General Public |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # License along with this library; if not, write to the |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # Free Software Foundation, Inc., |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # #################################################################### |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 from fife import fife |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 |
481
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
27 class SoundEmitter(object): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
28 def __init__(self, fifeemitter, clipid, soundname ): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
29 self._name = soundname |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
30 self._fifeemitter = fifeemitter |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
31 self._fifeclipid = clipid |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
32 self._gain = 255.0 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
33 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
34 def play(self, looping=False): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
35 self._fifeemitter.stop() |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
36 self._fifeemitter.setGain(float(self._gain)/255.0) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
37 self._fifeemitter.setLooping(looping) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
38 self._fifeemitter.play() |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
39 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
40 def stop(self): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
41 self._fifeemitter.stop() |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
42 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
43 def _getGain(self): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
44 return self._gain |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
45 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
46 def _setGain(self, gain): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
47 self._gain = float(gain) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
48 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
49 def _getClipID(self): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
50 return self._fifeclipid |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
51 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
52 def _getCallback(self): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
53 return self._callback |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
54 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
55 def _setCallback(self, cb): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
56 self._callback = cb |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
57 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
58 def _getFifeEmitter(self): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
59 return self._fifeemitter |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
60 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
61 def _setFifeEmitter(self, emitter): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
62 self._fifeemitter = emitter |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
63 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
64 clipid = property(_getClipID) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
65 gain = property(_setGain, _getGain) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
66 callback = property(_getCallback, _setCallback) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
67 fifeemitter = property(_getFifeEmitter, _setFifeEmitter) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
68 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
69 |
480
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 class SoundManager(object): |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 def __init__(self, engine): |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 self._engine = engine |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 self._soundmanager = self._engine.getSoundManager() |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 self._soundmanager.init() |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 |
481
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
77 self._emitters = list() |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
78 self._loadedclips = {} |
480
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 |
481
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
80 def createSoundEmitter(self, filename): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
81 if not filename in self._loadedclips: |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
82 clipid = self._engine.getSoundClipPool().addResourceFromFile(filename) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
83 fifeemitter = self._soundmanager.createEmitter() |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
84 fifeemitter.setSoundClip(clipid) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
85 self._loadedclips[filename] = clipid |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
86 emitter = SoundEmitter(fifeemitter, clipid, filename) |
480
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 else: |
481
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
88 fifeemitter = self._soundmanager.createEmitter() |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
89 fifeemitter.setSoundClip(self._loadedclips[filename]) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
90 emitter = SoundEmitter(fifeemitter, self._loadedclips[filename], filename) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
91 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
92 self._emitters.append(emitter) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
93 return emitter |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
94 |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
95 def stopAllSounds(self): |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
96 for emitter in self._emitters: |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
97 emitter.stop() |
480
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 def destroy(self): |
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 for emitter in self._emitters: |
481
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
101 emitter.stop() |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
102 self._soundmanager.releaseEmitter(emitter.fifeemitter.getID()) |
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
103 emitter.fifeemitter = None |
480
85fa5fa486a8
Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
104 |
481
1f37adc9a685
Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
480
diff
changeset
|
105 self._loadedclips.clear() |