本文整理匯總了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))