當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。