当前位置: 首页>>代码示例>>Python>>正文


Python mixer.init方法代码示例

本文整理汇总了Python中pygame.mixer.init方法的典型用法代码示例。如果您正苦于以下问题:Python mixer.init方法的具体用法?Python mixer.init怎么用?Python mixer.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygame.mixer的用法示例。


在下文中一共展示了mixer.init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sound_unicode

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def test_sound_unicode(self):
        """test non-ASCII unicode path"""
        mixer.init()
        import shutil
        ep = unicode_(example_path('data'))
        temp_file = os.path.join(ep, u'你好.wav')
        org_file = os.path.join(ep, u'house_lo.wav')
        shutil.copy(org_file, temp_file)
        try:
            with open(temp_file, 'rb') as f:
                pass
        except IOError:
            raise unittest.SkipTest('the path cannot be opened')

        try:
            sound = mixer.Sound(temp_file)
            del sound
        finally:
            os.remove(temp_file) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:21,代码来源:mixer_test.py

示例2: test_get_init__returns_exact_values_used_for_init

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def test_get_init__returns_exact_values_used_for_init(self):
        # fix in 1.9 - I think it's a SDL_mixer bug.

        # TODO: When this bug is fixed, testing through every combination
        #       will be too slow so adjust as necessary, at the moment it
        #       breaks the loop after first failure

        for init_conf in CONFIGS:
            frequency, size, channels
            if (frequency, size) == (22050, 16):
                continue
            mixer.init(frequency, size, channels)

            mixer_conf = mixer.get_init()

            self.assertEqual(init_conf, mixer_conf)
            mixer.quit() 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:19,代码来源:mixer_test.py

示例3: _init_pygame

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def _init_pygame(self):
        logging.info("INFO: loading pygame mixer")
        mixer.pre_init(44100, -16, 2, 2048)
        mixer.init() 
开发者ID:krahsdevil,项目名称:Retropie-CRT-Edition,代码行数:6,代码来源:bgm.py

示例4: play_sound

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def play_sound(self, input, streamer='pygame'):
        """Plays a sound
        
        Args:
            input (str): Input file
            streamer (str, optional): Streamer to use to play audio. Defaults to 'pygame'.
        
        Raises:
            NotImplementedError: `streamer` not defined
        """
        logger.warning('Playing sound {}'.format(input))
        if streamer == 'pygame':
            from pygame import mixer
            mixer.pre_init(44100, -16, 1, 512)
            mixer.init()
            mixer.music.load(input)
            mixer.music.play()
            while mixer.music.get_busy() == True:
                continue
        elif streamer == 'playsound': 
            from playsound import playsound
            playsound(input)
        elif streamer == 'os':
            import subprocess
            subprocess.call(['omxplayer', input])
        elif streamer == 'none':
            return 
        else:
            raise NotImplementedError 
开发者ID:chollinger93,项目名称:scarecrow,代码行数:31,代码来源:audio.py

示例5: speak_pygame

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def speak_pygame(self):
        mixer.init()
        mixer.pause()
        mixer.music.load(self.speak_result)
        mixer.music.play()
        self.hibernate()
        mixer.music.stop()
        mixer.unpause()
        mixer.quit() 
开发者ID:SlapBot,项目名称:stephanie-va,代码行数:11,代码来源:speaker.py

示例6: door_chime

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def door_chime(self):
        mixer.init()
        mixer.music.load(dirname(__file__) + '/sounds/door_chime.mp3')
        mixer.music.set_volume(self._settings.get('voice_volume', 100) / 100)
        mixer.music.play() 
开发者ID:bggardner,项目名称:simplisafe-rf,代码行数:7,代码来源:basestation.py

示例7: start_siren

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def start_siren(self):
        mixer.init()
        mixer.music.load(dirname(__file__) + '/sounds/siren.mp3')
        mixer.music.set_volume(self._settings.get('siren_volume', 100) / 100)
        mixer.music.play(-1) 
开发者ID:bggardner,项目名称:simplisafe-rf,代码行数:7,代码来源:basestation.py

示例8: __init__

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def __init__(self, **kwargs):
        mixer.init(frequency=44100, size=-16, channels=2, buffer=4096)
        mixer.music.load(settings.MUSIC)
        self.paused = True
        self.pause_time = 0
        self.initialized = False
        super().__init__(**kwargs) 
开发者ID:Contraz,项目名称:demosys-py,代码行数:9,代码来源:music.py

示例9: right

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def right(self):
        mixer.init()
        mixer.music.load('right.mp3')
        mixer.music.play() 
开发者ID:satinder147,项目名称:DeepWay,代码行数:6,代码来源:voice.py

示例10: left

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def left(self):
        mixer.init()
        mixer.music.load('left.mp3')
        mixer.music.play() 
开发者ID:satinder147,项目名称:DeepWay,代码行数:6,代码来源:voice.py

示例11: stop_left

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def stop_left(self):
        mixer.init()
        mixer.music.load('stop_left.mp3')
        mixer.music.play() 
开发者ID:satinder147,项目名称:DeepWay,代码行数:6,代码来源:voice.py

示例12: stop_right

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def stop_right(self):
        mixer.init()
        mixer.music.load('stop_right.mp3')
        mixer.music.play() 
开发者ID:satinder147,项目名称:DeepWay,代码行数:6,代码来源:voice.py

示例13: peopleOnRight

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def peopleOnRight(self):
        mixer.init()
        mixer.music.load('face_right.mp3')
        mixer.music.play() 
开发者ID:satinder147,项目名称:DeepWay,代码行数:6,代码来源:voice.py

示例14: sound

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def sound(error=False):
        mixer.init()
        mixer.music.load(notify.sound_warn if error else notify.sound_info)
        mixer.music.play() 
开发者ID:artyshko,项目名称:smd,代码行数:6,代码来源:main.py

示例15: _play_audio

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import init [as 别名]
def _play_audio(self):
        """Play the audio sample."""
        if not self._paused:
            if self._first_call:
                self._first_call = False
                mixer.init(48000, -16, 1, 1024)
                mixer.music.load(self._audio_file)
                self._set_volume()
                self._set_max_progress_bar()
            mixer.music.play()
        else:
            mixer.music.unpause()
            self._paused = False
        self._timer.start(self._TIME_STEP)
        self._enable_buttons(False, True, True) 
开发者ID:AresValley,项目名称:Artemis,代码行数:17,代码来源:audio_player.py


注:本文中的pygame.mixer.init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。