コード例 #1
0
 def playSound(self, sound):
     retVal = True
     if self.soundDict.get(sound) == None:
         logError('SoundEffectPlayer', 'playSound',
                  'sound [' + sound + '] not found in dict')
         retVal = False
         if sound != PRAM.SOUND_ERROR:  #prevent infinite recursion
             self.playSound(PRAM.SOUND_ERROR)
     else:
         self.soundDict[sound].soundObject.play()
     return retVal
コード例 #2
0
 def playSong(self, song, playthroughs=-1):
     retVal = True
     if self.musicDict.get(song) == None:
         logError('MusicPlayer', 'playSong',
                  'song [' + song + '] not found in dict')
         retVal = False
         if song != PRAM.SONG_ERROR:  #avoid infinite recursion
             self.playSong(PRAM.SONG_ERROR, 1)
     else:
         pygame.mixer.music.load(self.musicDict.get(song).fullPath)
         pygame.mixer.music.play(-1)
     return retVal
コード例 #3
0
 def setSoundVolume(self, sound, volume):
     retVal = True
     if volume > 1.0 or volume < 0:
         logError('SoundEffectPlayer', 'setSoundVolume',
                  'val ' + str(volume) + ' out of range')
         retVal = False
     elif self.soundDict.get(sound) == None:
         logError('SoundEffectPlayer', 'playSound',
                  'sound [' + sound + '] not found in dict')
         retVal = False
     else:
         self.soundDict.get(sound).soundObject.set_volume(volume)
     return retVal
コード例 #4
0
 def loadSong(self, soundWrapper):
     retVal = True
     if soundWrapper.soundType == 'song':
         if self.musicDict.get(soundWrapper.sound) == None:
             if (os.path.exists(str(soundWrapper.fullPath))):
                 self.musicDict[soundWrapper.sound] = soundWrapper
             else:
                 logError('MusicPlayer', 'loadSong',
                          'path [' + soundWrapper.fullPath + '] not found')
                 retVal = False
         else:
             logError(
                 'MusicPlayer', 'loadSong', 'tried to reload [' +
                 soundWrapper.fullPath + '], but this already exists')
             retVal = False
     else:
         retVal = False
         logError('MusicPlayer', 'loadSong',
                  'load song with type: ' + str(soundWrapper.soundType))
     return retVal
コード例 #5
0
 def loadSound(self, soundWrapper):
     retVal = True
     if soundWrapper.soundType == 'sound':
         if self.soundDict.get(soundWrapper.sound) == None:
             if (os.path.exists(str(soundWrapper.fullPath))):
                 soundWrapper.soundObject = pygame.mixer.Sound(
                     soundWrapper.fullPath
                 )  #save the sound file in the object
                 self.soundDict[soundWrapper.sound] = soundWrapper
             else:
                 logError('SoundEffectPlayer', 'loadSound',
                          'path [' + soundWrapper.fullPath + '] not found')
                 retVal = False
         else:
             logError(
                 'SoundEffectPlayer', 'loadSound', 'tried to reload [' +
                 soundWrapper.fullPath + '], but this already exists')
             retVal = False
     else:
         retVal = False
         logError('SoundEffectPlayer', 'loadSound',
                  'load sound with type: ' + str(soundWrapper.soundType))
     return retVal