source: trunk/PARPG/scripts/sounds.py @ 134

Revision 134, 1.4 KB checked in by maximinus_parpg, 11 years ago (diff)

Added basic SoundEngine? class.
Added new script sounds.py.
Plays background music.

Line 
1#!/usr/bin/python
2
3#   This file is part of PARPG.
4
5#   PARPG is free software: you can redistribute it and/or modify
6#   it under the terms of the GNU General Public License as published by
7#   the Free Software Foundation, either version 3 of the License, or
8#   (at your option) any later version.
9
10#   PARPG is distributed in the hope that it will be useful,
11#   but WITHOUT ANY WARRANTY; without even the implied warranty of
12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13#   GNU General Public License for more details.
14
15#   You should have received a copy of the GNU General Public License
16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>.
17
18# sounds.py holds the object code to play sounds and sound effects
19
20class SoundEngine:
21    def __init__(self, fife_engine):
22        self.engine = fife_engine
23        self.sound_engine = self.engine.getSoundManager()
24        self.sound_engine.init()
25        # set up the sound
26        self.music = self.sound_engine.createEmitter()
27   
28    def playMusic(self, sfile = None):
29        if(sfile != None):
30            # setup the new sound
31            sound = self.engine.getSoundClipPool().addResourceFromFile(sfile)
32            self.music.setSoundClip(sound)
33            self.music.setLooping(True)
34        self.music.play()
35   
36    def pauseMusic(self):
37        """Stop current playback"""
38        self.music.stop()
39
40    def setVolume(self, volume):
41        pass
42
Note: See TracBrowser for help on using the repository browser.