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

Python music.play函数代码示例

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

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



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

示例1: update

 def update(self, time):
   print ('update', self._filename, self._playing, time, self._start_time, self._end_time)
   if time < self._start_time: pass
   elif self._playing == 'no':
     try:
       music.stop()
       music.load(self._filename)
       music.set_volume(0.01) # 0.0 stops pygame.mixer.music.
       # Workaround for a pygame/libsdl mixer bug.
       #music.play(0, self._start)
       music.play(0, 0)
       self._playing = 'yes'
     except: # Filename not found? Song is too short? SMPEG blows?
       music.stop()
       self._playing = 'no'
   elif time < self._start_time + 1000: # mixer.music can't fade in
     music.set_volume((time - self._start_time) / 1000.0)
   elif (time > self._end_time - 1000) and self._playing == 'yes':
     self._playing = 'fadeout'
     music.fadeout(1000)
   elif time > self._end_time:
     music.stop()
     dt = pygame.time.get_ticks() + 1000 - self._start_time
     self._end_time = dt + self._end_time
     self._start_time = dt + self._start_time
     self._playing = 'no'
开发者ID:EvilDrW,项目名称:pydance,代码行数:26,代码来源:songselect.py


示例2: teclado

    def teclado(self, tecla, x, y):
        if tecla == b'a' and self.axisX >= -1:
            self.esqdir += - 20
            self.axisX -= .1

        if tecla == b's'and self.axisZ <= 1.7:
            self.cimabaixo += - 20
            self.axisZ += .1

        if tecla == b'w' and self.axisZ >= -12.8:
            self.cimabaixo += + 20
            self.axisZ -= .1

        if tecla == b'd' and self.axisX <= 6.9:
            self.esqdir += + 20
            self.axisX += .1

        # TRAVE - X 2.4 a 3.7
        if self.axisZ < -12.8 and 2.4 <= self.axisX <= 3.7:
            music.play(0)

        # 1.8 / 3.7 a 2.4
        if self.axisZ > 1.7 and 2.4 <= self.axisX <= 3.7:
            music.play(0)

        print self.axisX
        print self.axisZ

        glutPostRedisplay()
开发者ID:diogenesfilho,项目名称:Estadio,代码行数:29,代码来源:Complex.py


示例3: __init__

  def __init__(self, settings):
    self.speed = int(settings['-r']) if '-r' in settings else 20
    self.scale = float(settings['-s']) if '-s' in settings else 1.0
    self.screen = curses.initscr()
    self.height, self.width = self.screen.getmaxyx()#[:2]
    self.START_INTENSITY = int(settings['-i']) if '-i' in settings else self.MAX_INTENSITY
    self.START_OFFSET = int(settings['-w']) if '-w' in settings else 0
    self.START_HEIGHT = int(settings['-h']) if '-h' in settings else 0
    self.screen.clear()
    self.screen.nodelay(1)
    mixer.init()
    music.load('../fire.wav')
    music.play(-1)
    self.volume = 1.0

    curses.curs_set(0)
    curses.start_color()
    curses.use_default_colors()
    for i in range(0, curses.COLORS):
      curses.init_pair(i, i, -1)

    def color(r, g, b):
      return (196+r//48*6+g//48*36+b//48)
    self.heat = [color(16 * i,0,0) for i in range(0,16)] #+ [color(255,16 * i,0) for i in range(0,16)]
    self.particles = [ord(i) for i in (' ', '.', '*', '#', '@')]
    assert(len(self.particles) == self.NUM_PARTICLES)

    self.resize()
开发者ID:lispyfresh,项目名称:pyre,代码行数:28,代码来源:pyre.py


示例4: run

    def run(self):
        while True:
            target, nontarget, tname, ntname, evalue, word, t, count, allele = self.blastqueue.get()
            threadlock.acquire()
            if os.path.getsize(target) != 0:
                # BLASTn parameters
                blastn = NcbiblastnCommandline(query=target,
                                               db=nontarget,
                                               evalue=evalue,
                                               outfmt=6,
                                               perc_identity=85,
                                               word_size=word,
                                               # ungapped=True,
                                               # penalty=-20,
                                               # reward=1,
                                               )
                stdout, stderr = blastn()
                sys.stdout.write('[%s] [%s/%s] ' % (time.strftime("%H:%M:%S"), count, t))
                if not stdout:
                    print colored("%s has no significant similarity to \"%s\"(%i) with an elimination E-value: %g"
                                  % (tname, ntname, allele, evalue), 'red')

                else:
                    music.load('/run/media/blais/blastdrive/coin.wav')
                    music.play()
                    print colored("Now eliminating %s sequences with significant similarity to \"%s\"(%i) with an "
                                  "elimination E-value: %g" % (tname, ntname, allele, evalue), 'blue', attrs=['blink'])
                    blastparse(stdout, target, tname, ntname)
            else:
                global result
                result = None
            threadlock.release()
            self.blastqueue.task_done()
开发者ID:OLC-LOC-Bioinformatics,项目名称:SigSeekr,代码行数:33,代码来源:USSPpip.py


示例5: __init__

 def __init__(self):
   self._playing = False
   self._filename = None
   self._end_time = self._start_time = 0
   if not mainconfig["previewmusic"]:
     music.load(os.path.join(sound_path, "menu.ogg"))
     music.play(4, 0.0)
开发者ID:asb,项目名称:pydance,代码行数:7,代码来源:songselect.py


示例6: __init__

  def __init__(self, settings):
    self.speed = int(settings['-r']) if '-r' in settings else 20
    self.scale = float(settings['-s']) if '-s' in settings else 1.0
    self.screen = curses.initscr()
    self.START_INTENSITY = int(settings['-i']) if '-i' in settings else self.MAX_INTENSITY
    self.START_OFFSET = int(settings['-w']) if '-w' in settings else 0
    self.START_HEIGHT = int(settings['-h']) if '-h' in settings else 0
    self.screen.clear()
    self.screen.nodelay(1)

    curses.curs_set(0)
    curses.start_color()
    curses.use_default_colors()
    for i in range(0, curses.COLORS):
      curses.init_pair(i, i, -1)

    def color(r, g, b):
      return (16+r//48*36+g//48*6+b//48)
    self.heat = [color(16 * i,0,0) for i in range(0,16)] + [color(255,16 * i,0) for i in range(0,16)]
    self.particles = [ord(i) for i in (' ', '.', '*', '#', '@')]
    assert(len(self.particles) == self.NUM_PARTICLES)

    self.resize()
    self.volume = 1.0
    if pygame_available:
      mixer.init()
      music.load('fire.wav')
      music.play(-1)
    elif pyaudio_available:
      self.loop = True
      self.lock = threading.Lock()
      t = threading.Thread(target=self.play_fire)
      t.start()
开发者ID:digideskio,项目名称:pyre,代码行数:33,代码来源:pyre.py


示例7: play_bgm

 def play_bgm(self, path, stream=False):
     self.stop_current_channel()
     if stream:
         music.load(path)
         music.play(-1)
     else:
         self.current_channel = Sound(path).play(-1)
     self.set_volume()
开发者ID:ohsqueezy,项目名称:pgfw,代码行数:8,代码来源:Audio.py


示例8: start

 def start(self):
     #line
     music.load(os.path.join("games", "lineMathCombo", "finalSound.wav"))
     music.play()
     #maths
     self.answer = self.addans
     self.winner = False
     self.losing = 0
开发者ID:oneski,项目名称:SAAST-Summer-Program-Project,代码行数:8,代码来源:game.py


示例9: start

 def start(self, frame_rate):
     self.group.draw(self.screen)
     music.play(-1)
     self.running = True
     while self.running:
         deltaT = self.clock.tick(frame_rate)
         self.update(deltaT)
     if self.music:
         music.stop(self.music)
开发者ID:alephu5,项目名称:crispy-chainsaw,代码行数:9,代码来源:main.py


示例10: start

    def start(self):
        self._engine.render()  # initial render to init graphics
        self.put_robots()

        for robot in self._robots.itervalues():
            self.robot_born(robot)

        music.play()
        capture = self._config["system"]["capture"]
        paused = False
        while True:
            terminate = False
            for event in pygame.event.get():
                if event.type == QUIT:
                    terminate = True
                    break
                elif event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        terminate = True
                        break
                    elif event.key == K_SPACE:
                        paused = not paused
                        if paused:
                            music.pause()
                        else:
                            music.unpause()
            if terminate:
                break

            time_passed = self._engine.tick()
            if paused:
                continue

            for shoot in self._gp_shoots:
                shoot.step(self, time_passed)

            # TODO: terminate the game when all
            # robot of one team is dead
            all_dead = True
            for robot in self._robots.itervalues():
                if robot["k.alive"] == True:
                    all_dead = False
                    self.perform_action(robot, time_passed)

                if all_dead:
                    break
            self._engine.render()

            self.recover_property(time_passed, prop="cp")

            if capture:
                self._frames.append(self._engine.screen.copy())

        music.fadeout(1000)
        if capture:
            self.save_capture()
        sys.exit()
开发者ID:pluskid,项目名称:irobot2,代码行数:57,代码来源:god.py


示例11: start_next_music

def start_next_music():
    """Start playing the next item from the current playlist immediately."""
    #print "albow.music: start_next_music" ###
    global current_music, next_change_delay
    if music_enabled and current_playlist:
        next_music = current_playlist.next()
        if next_music:
            print "albow.music: loading", repr(next_music) ###
            music.load(next_music)
            music.play()
            next_change_delay = change_delay
        current_music = next_music
开发者ID:codewarrior0,项目名称:mcedit,代码行数:12,代码来源:music.py


示例12: orchestrate

def orchestrate(phonograph_name, once=False):
    if not SOUND_ON:
        return
    global MUSIC_PLAYING
    if MUSIC_PLAYING == phonograph_name:
        return
    path = data.filepath(os.path.join("numerical_phonographs", phonograph_name))
    if MUSIC_PLAYING:
        music.fadeout(1000)
    music.load(path)
    music.play(0 if once else -1)
    MUSIC_PLAYING = phonograph_name
开发者ID:scavpy,项目名称:Scav-Threads-PyWeek-Sep-2012,代码行数:12,代码来源:phonographs.py


示例13: playmusic

def playmusic(_file: str) -> None:
    """Play an MP3, WAV, or other audio file via Pygame3"""
    try:
        from pygame.mixer import init, music
    except ImportError:
        raise Exception(r'Pygame is not installed or found.')
    init()
    music.load(_file)
    music.play()
    while music.get_busy() is True:
        continue
    return None
开发者ID:kaiHooman,项目名称:Pybooster,代码行数:12,代码来源:basic.py


示例14: __init__

  def __init__(self, songs, courses, screen, game):
    InterfaceWindow.__init__(self, screen, "courseselect-bg.png")

    recordkeys = dict([(k.info["recordkey"], k) for k in songs])

    self._courses = [CourseDisplay(c, recordkeys, game) for c in courses]
    self._all_courses = self._courses
    self._index = 0
    self._clock = pygame.time.Clock()
    self._game = game
    self._config = dict(game_config)
    self._configs = []

    self._list = ListBox(FontTheme.Crs_list,
                         [255, 255, 255], 32, 10, 256, [373, 150])
    if len(self._courses) > 60 and mainconfig["folders"]:
      self._create_folders()
      self._create_folder_list()
    else:
      self._folders = None
      self._base_text = _("All Courses")
      self._courses.sort(SORTS[SORT_NAMES[mainconfig["sortmode"] % NUM_SORTS]])
      self._list.set_items([s.name for s in self._courses])

    self._course = self._courses[self._index]
    self._course.render()

    players = games.GAMES[game].players

    for i in range(players):
      self._configs.append(dict(player_config))

    ActiveIndicator([368, 306], height = 32, width = 266).add(self._sprites)
    HelpText(CS_HELP, [255, 255, 255], [0, 0, 0], FontTheme.help,
             [186, 20]).add(self._sprites)

    self._list_gfx = ScrollingImage(self._course.image, [15, 80], 390)
    self._coursetitle = TextDisplay('Crs_course_name', [345, 28], [20, 56])
    self._title = TextDisplay('Crs_course_list_head', [240, 28], [377, 27])
    self._banner = ImageDisplay(self._course.banner, [373, 56])
    self._sprites.add([self._list, self._list_gfx, self._title,
                       self._coursetitle, self._banner])
    self._screen.blit(self._bg, [0, 0])
    pygame.display.update()
    self.loop()
    music.fadeout(500)
    pygame.time.wait(500)
    # FIXME Does this belong in the menu code? Probably.
    music.load(os.path.join(sound_path, "menu.ogg"))
    music.set_volume(1.0)
    music.play(4, 0.0)
    player_config.update(self._configs[0]) # Save p1's settings
开发者ID:EvilDrW,项目名称:pydance,代码行数:52,代码来源:courseselect.py


示例15: play

 def play(self,file,cdImage=None,pos=0.0):
     '''
     play a music file (file)
     show the cdImage(album art) if passed.
     '''
     print "Starting playback of: "+file;
     self.meta=self.parseMetadata(file);
     music.load(file);
     if(cdImage!=None):
         img=pygame.image.load(cdImage);
         self.cdImg=pygame.transform.scale(img, (75,75))
     else:
         self.cdImg=self.emptyCD;
     self.forceRefresh=True;
     music.play(0,pos);
开发者ID:tcolar,项目名称:Stylus2X,代码行数:15,代码来源:Music.py


示例16: input

    def input(self, event, next_state):
        next_state = super(InGame, self).input(event, next_state)

        if event.type == KEYDOWN:
            if event.key == K_ESCAPE:
                next_state = set_next_state(next_state, STATES.MENU)
            elif event.key == K_m:
                if music.get_busy():
                    music.stop()
                else:
                    music.play()

        self.camera.input(event)
        self.unitmgr.input(event, self.camera, self.mouse_rect, self.tilemgr)
        self.input_mouse(event)

        return next_state
开发者ID:drtchops,项目名称:iancraft,代码行数:17,代码来源:ingame.py


示例17: set_music_enabled

def set_music_enabled(state):
    global music_enabled
    if music_enabled != state:
        music_enabled = state
        if state:
            # Music pausing doesn't always seem to work.
            #music.unpause()
            if current_music:
                # After stopping and restarting currently loaded music,
                # fadeout no longer works.
                #print "albow.music: reloading", repr(current_music) ###
                music.load(current_music)
                music.play()
            else:
                jog_music()
        else:
            #music.pause()
            music.stop()
开发者ID:codewarrior0,项目名称:mcedit,代码行数:18,代码来源:music.py


示例18: play

 def play(self,filename,loops=-1,start=0.0):
     if not self.filename:
         self.stop()
     self.filename = filename
     try:
         music.load(filename)
     except:
         print "bad filename or i/o error on "+filename+"check file name and its status"
         
     self.channel = music.play(loops,start)
开发者ID:gdos,项目名称:simple-adv,代码行数:10,代码来源:musicfx.py


示例19: update

 def update(self, time):
   if self._filename is None: pass
   elif time < self._start_time: pass
   elif not self._playing:
     try:
       music.stop()
       music.load(self._filename)
       music.set_volume(0.01) # 0.0 stops pygame.mixer.music.
       # Workaround for a pygame/libsdl mixer bug.
       #music.play(0, self._start)
       music.play(0, 0)
       self._playing = True
     except: # Filename not found? Song is too short? SMPEG blows?
       music.stop()
       self.playing = False
   elif time < self._start_time + 1000: # mixer.music can't fade in
     music.set_volume((time - self._start_time) / 1000.0)
   elif time > self._end_time - 1000:
     music.fadeout(1000)
     self._playing = False
     self._filename = None
开发者ID:asb,项目名称:pydance,代码行数:21,代码来源:songselect.py


示例20: setcolors

def setcolors():
    global state, r, g, b
    global play
    while 1:
        if state == 'b0':
            a.timedfade(r,g,b,1)
            music.stop()
            play = False
            state = 'b1'
        elif state == 'b1':
            time.sleep(.1)
        elif state == 'r1':
            a.timedfade(255,0,0,.4)
            if not play:
            	music.play(-1)
                play = True
            state = 'r2'
            time.sleep(.4);
        elif state == 'r2':
            a.timedfade(0,0,0,.4)
            state = 'r1'
            time.sleep(.4)
开发者ID:schneider42,项目名称:uberbus,代码行数:22,代码来源:switchsiren.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python mouse.get_pos函数代码示例发布时间:2022-05-25
下一篇:
Python music.load函数代码示例发布时间: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