本文整理汇总了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
示例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()
示例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)
示例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'])
示例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))
示例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))