• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mixer.quit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_get_raw_more

    def test_get_raw_more(self):
        """ test the array interface a bit better.
        """
        import platform
        IS_PYPY = 'PyPy' == platform.python_implementation()

        if IS_PYPY:
            return
        from ctypes import pythonapi, c_void_p, py_object

        try:
            Bytes_FromString = pythonapi.PyBytes_FromString
        except:
            Bytes_FromString = pythonapi.PyString_FromString
        Bytes_FromString.restype = c_void_p
        Bytes_FromString.argtypes = [py_object]
        mixer.init()
        try:
            samples = as_bytes('abcdefgh') # keep byte size a multiple of 4
            snd = mixer.Sound(buffer=samples)
            raw = snd.get_raw()
            self.assertTrue(isinstance(raw, bytes_))
            self.assertNotEqual(snd._samples_address, Bytes_FromString(samples))
            self.assertEqual(raw, samples)
        finally:
            mixer.quit()
开发者ID:Yarrcad,项目名称:CPSC-386-Pong,代码行数:26,代码来源:mixer_test.py


示例2: playBell

def playBell(name, t):
    mixer.init()
    print name
    sound = mixer.Sound(name)
    sound.play()
    time.sleep(t)
    mixer.quit()
开发者ID:mbbbackus,项目名称:Bells_Code,代码行数:7,代码来源:bellAudio.py


示例3: submit

 def submit(self):
     self.submit_button.configure(state=DISABLED)
     self.play_button.configure(state=DISABLED)
     for item in self.stuff_to_disable:
         item.configure(state=DISABLED)
     
     try:
         mixer.quit()
     except error: # pygame.error
         pass # music was never played, so we can't stop it
     
     right = 0
     wrong = []
     
     excerpt = "A"
     for piece in self.order:
         questions = self.questions[piece].keys()
         questions.reverse() # correct question ordering
         for question in questions:
             correct_answer = config.get(piece, question)
             given_answer = self.answers[piece][question].get()
             if given_answer == u"Der Erlk\xf6nig": # unicode bugfix
                 given_answer = "Der Erlk\xc3\xb6nig"
             if correct_answer == given_answer:
                 right += 1
             else:
                 wrong.append((excerpt, config.get(piece, "title"),
                         question, given_answer, correct_answer))
         excerpt = chr(ord(excerpt) + 1)
     
     results = Toplevel() # make a new window to display results
     results.title("Results")
     
     noq = self.number_of_questions
     text = "{0} of {1} answered correctly ({2}%):".format(right, noq,
             round((right / noq) * 100, 2))
     
     if right == noq:
         text += "\n\nCongratulations, you got everything right!"
     
     else:
         text += "\n"
         for excerpt, title, question, given_answer, correct_answer in wrong:
             if not given_answer:
                 if question == "title":
                     text += "\nYou left the title of Excerpt {0} blank; it's \"{1}\".".format(
                             excerpt, correct_answer)
                 else:
                     text += "\nYou left the {0} of \"{1}\" blank; it's {2}.".format(
                             question, title, correct_answer)
             elif question == "title":
                 text += "\nExcerpt {0} was {1}, not {2}.".format(
                         excerpt, correct_answer, given_answer)
             else:
                 text += "\nThe {0} of \"{1}\" is {2}, not {3}.".format(
                         question, title, correct_answer, given_answer)
         
     label = Label(results, text=text, justify=LEFT, padx=15, pady=10,
             font=Font(family="Verdana", size=8))
     label.pack()
开发者ID:earwig,项目名称:music-quizzer,代码行数:60,代码来源:musicquizzer.py


示例4: test_get_init__returns_exact_values_used_for_init

    def test_get_init__returns_exact_values_used_for_init(self):
        return 
        # 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

        configs = []
        for f in FREQUENCIES:
            for s in SIZES:
                for c in CHANNELS:
                    configs.append ((f,s,c))

        print (configs)
    

        for init_conf in configs:
            print (init_conf)
            f,s,c = init_conf
            if (f,s) == (22050,16):continue
            mixer.init(f,s,c)

            mixer_conf = mixer.get_init()
            import time
            time.sleep(0.1)

            mixer.quit()
            time.sleep(0.1)

            if init_conf != mixer_conf:
                continue
            self.assertEquals(init_conf, mixer_conf)
开发者ID:IuryAlves,项目名称:pygame,代码行数:33,代码来源:mixer_test.py


示例5: todo_test_pre_init__keyword_args

    def todo_test_pre_init__keyword_args(self):
        # Fails on Mac; probably older SDL_mixer
## Probably don't need to be so exhaustive. Besides being slow the repeated
## init/quit calls may be causing problems on the Mac.
##        configs = ( {'frequency' : f, 'size' : s, 'channels': c }
##                    for f in FREQUENCIES
##                    for s in SIZES
##                    for c in CHANNELS )
        configs = [{'frequency' : 44100, 'size' : 16, 'channels' : 1}]

        for kw_conf in configs:
            mixer.pre_init(**kw_conf)
            mixer.init()

            mixer_conf = mixer.get_init()
            
            self.assertEquals(
                # Not all "sizes" are supported on all systems.
                (mixer_conf[0], abs(mixer_conf[1]), mixer_conf[2]),
                (kw_conf['frequency'],
                 abs(kw_conf['size']),
                 kw_conf['channels'])
            )
            
            mixer.quit()
开发者ID:IuryAlves,项目名称:pygame,代码行数:25,代码来源:mixer_test.py


示例6: playSound

 def playSound(self):
    #spielt einen Sound ab
    try:
        CHUNK = 1024;
        wf = wave.open(self.newName, 'rb')
        p = pyaudio.PyAudio()
        stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
                        channels=wf.getnchannels(),
                        rate=wf.getframerate(),
                        output=True)
        data = wf.readframes(CHUNK)          
        while data != '':
            stream.write(data)
            data = wf.readframes(CHUNK)
        stream.stop_stream()
        stream.close()            
        p.terminate()
    except:
        mixer.init()
        mixer.music.load(self.newName)
        mixer.music.play(1,0.0)
        while mixer.music.get_busy():
            pass
        mixer.quit()           
    return 	
开发者ID:xxxAdrianxxx,项目名称:HS_EDA,代码行数:25,代码来源:soundlibkosc.py


示例7: test_get_num_channels__defaults_eight_after_init

    def test_get_num_channels__defaults_eight_after_init(self):
        mixer.init()
        
        num_channels = mixer.get_num_channels()

        self.assert_(num_channels == 8)

        mixer.quit()
开发者ID:IuryAlves,项目名称:pygame,代码行数:8,代码来源:mixer_test.py


示例8: test_set_num_channels

    def test_set_num_channels(self):
        mixer.init()

        for i in xrange_(1, mixer.get_num_channels() + 1):
            mixer.set_num_channels(i)
            self.assert_(mixer.get_num_channels() == i)

        mixer.quit()
开发者ID:IuryAlves,项目名称:pygame,代码行数:8,代码来源:mixer_test.py


示例9: play_sound

def play_sound(sound_file):

    mix.init()
    mix.music.load(sound_file)
    mix.music.play()
    while mix.music.get_busy():
        continue
    mix.quit()
    logging.debug('Playing sound: %s', sound_file)
开发者ID:bbbenji,项目名称:doorpi2,代码行数:9,代码来源:tasks.py


示例10: speak_pygame

 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:KahuthuJeff,项目名称:stephanie-va,代码行数:9,代码来源:speaker.py


示例11: finalize

def finalize():
   print 1
   PDI.quit()
   print 2
   PX.quit()
   print 3
   PG.quit()
   print 4
   SYS.exit()
   print 5
开发者ID:davidmvp,项目名称:cryptography,代码行数:10,代码来源:GameFrame.py


示例12: close_sound

def close_sound(experiment):

    """
	Closes the mixer after the experiment is finished.

	Arguments:
	experiment -- An instance of libopensesame.experiment.experiment
	"""

    mixer.quit()
开发者ID:rsprouse,项目名称:OpenSesame,代码行数:10,代码来源:legacy.py


示例13: Load

 def Load(self, filename):
     with audioread.audio_open(filename) as f:
         self.duration = int(f.duration * 1000)
         self.samplerate = f.samplerate
         self.channels = f.channels
     mixer.quit()
     mixer.init(frequency=self.samplerate, channels=self.channels)
     music.load(filename)
     self.pos = 0
     self.has_music = True
开发者ID:sdukhovni,项目名称:karaoke-chan,代码行数:10,代码来源:player.py


示例14: todo_test_init__zero_values

 def todo_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)  # None default values
     mixer.init(0, 0, 0)
     try:
         self.failUnlessEqual(mixer.get_init(), (44100, 8, 1))
     finally:
         mixer.quit()
         mixer.pre_init(0, 0, 0, 0)
开发者ID:IuryAlves,项目名称:pygame,代码行数:10,代码来源:mixer_test.py


示例15: test_quit

    def test_quit(self):
        """ get_num_channels() Should throw pygame.error if uninitialized
        after mixer.quit() """

        mixer.init()
        mixer.quit()

        self.assertRaises (
            pygame.error, mixer.get_num_channels,
        )
开发者ID:IuryAlves,项目名称:pygame,代码行数:10,代码来源:mixer_test.py


示例16: test_get_raw

 def test_get_raw(self):
     mixer.init()
     try:
         samples = b'abcdefgh' # keep byte size a multiple of 4
         snd = mixer.Sound(buffer=samples)
         raw = snd.get_raw()
         self.assertTrue(isinstance(raw, bytes_))
         self.assertEqual(raw, samples)
     finally:
         mixer.quit()
开发者ID:CTPUG,项目名称:pygame_cffi,代码行数:10,代码来源:mixer_test.py


示例17: test_load_buffer_bytearray

 def test_load_buffer_bytearray(self):
     """Test loading from various buffer objects."""
     mixer.init()
     try:
         samples = b'\x00\xff' * 24
         snd = mixer.Sound(bytearray(samples))
         raw = snd.get_raw()
         self.assertTrue(isinstance(raw, bytes_))
         self.assertEqual(raw, samples)
     finally:
         mixer.quit()
开发者ID:CTPUG,项目名称:pygame_cffi,代码行数:11,代码来源:mixer_test.py


示例18: init_sound

def init_sound():
    """ Initialise sound system. """
    if not numpy:
        logging.warning('NumPy module not found. Failed to initialise audio.')
        return False
    if not mixer:
        return False    
    # initialise mixer as silent
    # this takes 0.7s but is necessary to be able to set channels to mono
    mixer.quit()    
    return True
开发者ID:boriel,项目名称:pcbasic,代码行数:11,代码来源:audio_pygame.py


示例19: handler

def handler(signal, frame):
    try:
        # Close and quit everything on CTRL+C
        midi.close()
        pymidi.quit()
        pymix.quit()
        pygame.quit()
    except Exception:
        pass

    sys.exit(0)
开发者ID:jtyr,项目名称:pystik,代码行数:11,代码来源:pystick.py


示例20: NEWBUF_test_newbuf

 def NEWBUF_test_newbuf(self):
     mixer.init(22050, -16, 1)
     try:
         self.NEWBUF_export_check()
     finally:
         mixer.quit()
     mixer.init(22050, -16, 2)
     try:
         self.NEWBUF_export_check()
     finally:
         mixer.quit()
开发者ID:Yarrcad,项目名称:CPSC-386-Pong,代码行数:11,代码来源:mixer_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mixer.Sound类代码示例发布时间:2022-05-25
下一篇:
Python mixer.pre_init函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap