Skip to content Skip to sidebar Skip to footer

Preloading Sound In Kivy

I have a kivy-based game that is supposed to play some sound FX. Sound objects are loaded like this: self.boombox = {'moved': SoundLoader.load('dshoof.wav'), 'attac

Solution 1:

It can be hacked around, as it turned out. All I needed was to set the player to the start of the file explicitly:

self.boombox = {'moved': SoundLoader.load('dshoof.wav'),
                'attacked': SoundLoader.load('dspunch.wav')}
for sound in self.boombox.keys():
    self.boombox[sound].seek(0)

As something like that would've been done anyway, it changes nothing about the sound. However, it forces sound provider to read the file right now instead of waiting until it's called. And, of course, this can be easily done during level loading instead of messing with the gameplay.


Post a Comment for "Preloading Sound In Kivy"