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

Python music.load函数代码示例

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

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



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

示例1: __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


示例2: __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


示例3: 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


示例4: 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


示例5: __init__

 def __init__(self, resourcemgr, team, level):
     super(InGame, self).__init__(resourcemgr)
     self.tilemgr = TileManager(resourcemgr, level)
     self.unitmgr = UnitManager(resourcemgr, STATES.INGAME, team, level)
     self.lw = self.tilemgr.lw
     self.lh = self.tilemgr.lh
     self.team = team
     # self.bar = Bar(config)
     music.load(os.path.join(resourcemgr.main_path, 'sound/yyz.ogg'))
     self.camera = Camera(0, 0, self.lw, self.lh, resourcemgr)
     font = SysFont(FONTS, int(48 * resourcemgr.scale), True)
     self.win_msg = font.render('YOU WINNN!!! GGGG GGGGGGGGGGGGGGG', 1,
         WHITE)
     self.win_msg_rect = self.win_msg.get_rect(
         centerx=self.camera.rect.w / 2, centery=self.camera.rect.h / 4)
     self.lose_msg = font.render('You lost. What the fuck, man?', 1,
         BLACK)
     self.lose_msg_rect = self.win_msg.get_rect(
         centerx=self.camera.rect.w / 2, centery=self.camera.rect.h / 4)
     self.mouse_rect = Rect(0, 0, 0, 0)
     self.x_first = 0
     self.y_first = 0
     self.won = False
     self.lost = False
     self.gg = load_sound(resourcemgr.main_path, 'gg.ogg')
     self.lose = load_sound(resourcemgr.main_path, 'lose.ogg')
开发者ID:drtchops,项目名称:iancraft,代码行数:26,代码来源:ingame.py


示例6: __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


示例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: 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


示例10: 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


示例11: 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


示例12: 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


示例13: __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


示例14: __init__

 def __init__(self):
     music.load("../objs/torcidaASA.mp3")
     self.obj = GLuint()
     glEnable(GL_DEPTH_TEST)
     glEnable(GL_NORMALIZE)
     glEnable(GL_COLOR_MATERIAL)
     self.quad = gluNewQuadric()
     self.textura1 = ''
     self.axisX = 3.5
     self.axisZ = -5
     self.esqdir = 0
     self.cimabaixo = 0
     self.texturaID = GLuint()
     self._textureID = self.carrega_textura("../objs/soccer_ball.jpeg")
开发者ID:diogenesfilho,项目名称:Estadio,代码行数:14,代码来源:Complex.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: __init__

 def __init__(self, screen_size, map, bgmusic=None):
     pygame.init()
     #pygame.mixer.init()
     self.screen_size = screen_size
     self.screen = pygame.display.set_mode(screen_size)
     self.rect = self.screen.get_rect()
     self.clock = pygame.time.Clock()
     self.map = load_pygame(map)
     self.running = False
     self.group = pyscroll.PyscrollGroup()
     self.obstacles = pygame.sprite.Group()
     # Use pyscroll to ensure that the camera tracks the player and does
     # not go off the edge.
     map_data = pyscroll.TiledMapData(self.map)
     map_layer = pyscroll.BufferedRenderer(
         map_data,
         screen_size,
         clamp_camera=True)
     self.group = pyscroll.PyscrollGroup(
         map_layer=map_layer,
         default_layer=1)
     if bgmusic:
         self.music = music.load(bgmusic)
         print(bgmusic)
     else:
         self.music = None
开发者ID:alephu5,项目名称:crispy-chainsaw,代码行数:26,代码来源:main.py


示例17: play

 def play(self):
     u"""音楽を再生する。ループに放り込んで使う"""
     if not self.stop:
         if not self.loopfile:
             if not self.looping and not music.get_busy():
                 music.play(self.loop)
                 self.looping = True
         else:  # イントロとループに分かれてる場合
             if self.intro:  # イントロ再生要求時
                 if not music.get_busy():
                     music.play()
                 self.intro = False
             else:
                 if not self.looping:
                     if not music.get_busy():
                         music.load(self.loopfile)
                         music.play(-1)
                         self.looping = True
开发者ID:giginet,项目名称:FormationPuzzle,代码行数:18,代码来源:bgm.py


示例18: 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


示例19: __init__

    def __init__(self, config):
        self._config = config
        self._robots = dict()
        self._engine = Engine(self._config["engine"])

        self._gp_robots = Group()
        self._gp_animations = Group()
        self._gp_shoots = Group()
        self._gp_overlays = Group()
        self._engine.add_group(self._gp_robots)
        self._engine.add_group(self._gp_animations)
        self._engine.add_group(self._gp_shoots)
        self._engine.add_group(self._gp_overlays)

        if self._config["system"]["capture"]:
            self._frames = []

        self._teams = {}

        music.load(path.join(self._engine.resource_base_path, "sound", self._config["system"]["bg_music"]))
开发者ID:pluskid,项目名称:irobot2,代码行数:20,代码来源:god.py


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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