本文整理汇总了Python中pygame.mixer.music.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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()
示例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()
示例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'
示例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')
示例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)
示例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()
示例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
示例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)
示例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
示例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
示例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
示例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
示例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")
示例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);