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


Python mixer.pre_init方法代码示例

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


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

示例1: play_sound

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import pre_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

示例2: _init_pygame

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import pre_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

示例3: tearDown

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import pre_init [as 别名]
def tearDown(self):
        mixer.quit()
        mixer.pre_init(0, 0, 0, 0) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:5,代码来源:mixer_test.py

示例4: test_pre_init__keyword_args

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import pre_init [as 别名]
def test_pre_init__keyword_args(self):
        # note: this test used to loop over all CONFIGS, but it's very slow..
        mixer.pre_init(**CONFIG)
        mixer.init()

        mixer_conf = mixer.get_init()

        self.assertEqual(mixer_conf[0], CONFIG['frequency'])
        # Not all "sizes" are supported on all systems,  hence "abs".
        self.assertEqual(abs(mixer_conf[1]), abs(CONFIG['size']))
        self.assertEqual(mixer_conf[2], CONFIG['channels']) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:13,代码来源:mixer_test.py

示例5: test_pre_init__zero_values

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import pre_init [as 别名]
def test_pre_init__zero_values(self):
        # Ensure that argument values of 0 are replaced with
        # default values. No way to check buffer size though.
        mixer.pre_init(44100, -8, 1)  # Non default values
        mixer.pre_init(0, 0, 0)       # Should reset to default values
        mixer.init()
        self.assertEqual(mixer.get_init(), (22050, -16, 2)) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:9,代码来源:mixer_test.py

示例6: test_init__zero_values

# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import pre_init [as 别名]
def test_init__zero_values(self):
        # Ensure that argument values of 0 are replaced with
        # preset values. No way to check buffer size though.
        mixer.pre_init(44100, 8, 1, allowedchanges=0)  # None default values
        mixer.init(0, 0, 0)
        self.assertEqual(mixer.get_init(), (44100, 8, 1)) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:8,代码来源:mixer_test.py


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