Пример #1
0
 def play(self, sound, loops=0, maxtime=-1, fade_ms=0):
     """play Sound on this channel"""
     # Note: channelnum will equal self.chan
     if fade_ms > 0:
         channelnum = sdl.Mix_FadeInChannelTimed(self.chan, sound.chunk,
                                                 loops, fade_ms, maxtime)
     else:
         channelnum = sdl.Mix_PlayChannelTimed(self.chan, sound.chunk,
                                               loops, maxtime)
     if channelnum != -1:
         sdl.Mix_GroupChannel(channelnum, sound._chunk_tag)
     _channeldata[channelnum].sound = sound
     _channeldata[channelnum].queue = None
Пример #2
0
    def play(self, loops=0, maxtime=-1, fade_ms=0):
        """play(loops=0, maxtime=-1, fade_ms=0) -> Channel
        begin sound playback"""
        if fade_ms > 0:
            channelnum = sdl.Mix_FadeInChannelTimed(-1, self.chunk, loops,
                                                    fade_ms, maxtime)
        else:
            channelnum = sdl.Mix_PlayChannelTimed(-1, self.chunk, loops,
                                                  maxtime)
        if channelnum < 0:
            # failure
            return None

        _channeldata[channelnum].sound = self
        _channeldata[channelnum].queue = None
        sdl.Mix_Volume(channelnum, 128)
        sdl.Mix_GroupChannel(channelnum, self._chunk_tag)
        return Channel(channelnum)