Ejemplo n.º 1
0
Archivo: me.py Proyecto: bluepeppers/me
 def play_sound(self, name):
     if android:
         import android_mixer as mixer
     else:
         from pygame import mixer
         mixer.init()
     sound = mixer.Sound(os.path.join("data", "{0}.ogg".format(name)))
     sound.play()
Ejemplo n.º 2
0
 def play_sound(self, name):
     if android:
         import android_mixer as mixer
     else:
         from pygame import mixer
         mixer.init()
     sound = mixer.Sound(os.path.join("data", "{0}.ogg".format(name)))
     sound.play()
Ejemplo n.º 3
0
    def __init__(self):

        """ Inits the sound handler object. """

        # Init pygame mixer.
        mixer.init()
        self.sfx = {
            0: ["", mixer.Channel(1), 0, 0, 0],
            1: ["", mixer.Channel(2), 0, 0, 0],
            2: ["", mixer.Channel(3), 0, 0, 0],
            3: ["", mixer.Channel(4), 0, 0, 0],
        }
Ejemplo n.º 4
0
from kivy.clock import Clock
from kivy.utils import platform
from . import Sound, SoundLoader

try:
    if platform() == 'android':
        import android_mixer as mixer
    else:
        import pygame.mixer as mixer
except:
    raise

# init pygame sound
mixer.pre_init(44100, -16, 2, 1024)
mixer.init()
mixer.set_num_channels(32)


class SoundPygame(Sound):

    # XXX we don't set __slots__ here, to automaticly add
    # a dictionnary. We need that to be able to use weakref for
    # SoundPygame object. Otherwise, it failed with:
    # TypeError: cannot create weak reference to 'SoundPygame' object
    # We use our clock in play() method.
    # __slots__ = ('_data', '_channel')
    @staticmethod
    def extensions():
        return ('wav', 'ogg', )