def is_over(self): if not music.get_busy(): return True elif self.endat and music.get_pos() > self.endat * 1000: music.stop() return True else: return False
def jog_music(): """ If no music is currently playing, start playing the next item from the current playlist. """ if music_enabled and not music.get_busy(): MusicUtilities.start_next_music()
def play_click(self, music_file): while True: if music.get_busy(): music.stop() else: break t = threading.Thread(target=self.__play, args=[music_file]) t.start()
def play_music(self): if music_player.get_busy(): return music_player.load(MUSIC[self.current_track]) music_player.play(1) self.current_track += 1 if self.current_track == len(MUSIC): self.current_track = 0
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
def __init__(self): mixer.init() global text1, text2, text3, text4 MU.load("activation.mp3") MU.play() while MU.get_busy(): time.sleep(.01) MU.load("name.mp3") MU.play() while MU.get_busy(): time.sleep(.01) text1 = V.Voice.get_voice_input() text.box1(text1, True) D.flip() MU.load("order.mp3") MU.play() while MU.get_busy(): time.sleep(.01) order = V.Voice.get_voice_input() if order == "1": buttons.Button1(True) if order == "2": buttons.Button2(True) if order == "3": buttons.Button3(True) if order == "4": buttons.Button4(True) D.flip() MU.load("phone_no.mp3") MU.play() while MU.get_busy(): time.sleep(.01) phone = V.Voice.get_voice_input() for digit in phone: if digit != ' ': text2 += digit text.box2(text2, True) D.flip() MU.load("email.mp3") MU.play()
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
def updateScreen(self,fullUpdate=True): start=20; gap=18; if(fullUpdate or self.forceRefresh): self.forceRefresh=False; # draw background & buttons self.screen.blit(self.musicImage,(0,0)); pygame.draw.line(self.screen,(0,0,150,200),(0,120),(320,120),2) self.screen.blit(self.buttonPlay,(0,20)); self.screen.blit(self.buttonPrev,(0,53)); self.screen.blit(self.buttonNext,(0,86)); self.screen.blit(self.buttonLoad,(0,120)); self.screen.blit(self.buttonSave,(0,150)); self.screen.blit(self.buttonAdd,(0,180)); self.screen.blit(self.buttonNew,(0,210)); #song/artist/album etc.. infos self.screen.blit(self.cdImg,(65,25,75,75)) self.drawText(self.meta['artist'],(0,250,0,200),(145,start)); self.drawText(self.meta['album'],(150,150,250,200),(145,start+gap)); self.drawText(self.meta['tracknumber']+": "+self.meta['title'],(250,50,50,200),(145,start+gap*2)); self.drawText(self.meta['date'],(200,200,200,200),(145,start+gap*3)); #TODO: show volume somewhere self.main.paintMenuBar(); #playlist self.playlist.drawPane(self,(70,130)); else: # clear the areas that need to refresh (progressbar & indicator); pygame.draw.rect(self.screen,(0,0,0,255),(145,start+gap*4,160,10)); pygame.draw.rect(self.screen,(0,0,0,255),(70,105,240,11)); # needs to be done wether full or light update # progress bar pygame.draw.line(self.screen,(100,100,100,200),(75,110),(305,110),10) pygame.draw.line(self.screen,(200,200,250,200),(75,110),(305,110),2) posX=75; length=self.meta['length']; progress=str(music.get_pos()/60000)+":"+str(music.get_pos()/1000%60)+" / --:--"; if(length>0): if(music.get_busy()): posX=75+(305-75)/1000.0*music.get_pos()/length progress=str(music.get_pos()/60000)+":"+str(music.get_pos()/1000%60)+" / "+str(int(length/60))+":"+str(int(length%60)) pygame.draw.line(self.screen,(150,150,250,255),(posX,105),(posX,115),5) self.drawText(progress+" Vol:50%",(200,100,200,200),(145,start+gap*4)); pygame.display.flip();
def play_sound(desire): """Given the name of an mp3 (no extension/dir), plays the sound. Args: desire (str): MP3 to play with no extension/dir. Returns: str: The action I just performed. """ # Ensure the mixer has been initialized if not mixer.get_init(): return 'Mixer has not been initialized yet; create a new instance.' music.load('sounds/{}.mp3'.format(desire)) music.play() while music.get_busy(): continue return "Played {}.".format(desire)
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
def playmusic(_filename: str) -> None: """Play an MP3, WAV, or other audio files""" if PYGAME_IMPORTED: init() music.load(_filename) music.play() while music.get_busy() is True: continue elif is_program_aval(r'ffplay'): _process = Popen(shlex.split(r'ffplay -hide_banner -loglevel panic -sn -vn -nodisp ' + _filename), stdout=PIPE, stderr=PIPE) _stdout, _stderr = _process.communicate() elif is_program_aval(r'play'): _process = Popen(shlex.split(r'play -q -V1 ' + _filename), stdout=PIPE, stderr=PIPE) _stdout, _stderr = _process.communicate() elif _filename.endswith(r'.mp3') and is_program_aval(r'mpeg321'): _process = Popen(shlex.split(r'mpg321 --quiet ' + _filename), stdout=PIPE, stderr=PIPE) _stdout, _stderr = _process.communicate() elif _filename.endswith(r'.mp3') and is_program_aval(r'mpg123'): _process = Popen(shlex.split(r'mpg123 --quiet ' + _filename), stdout=PIPE, stderr=PIPE) _stdout, _stderr = _process.communicate() elif _filename.endswith(r'.ogg') and is_program_aval(r'ogg123'): _process = Popen(shlex.split(r'ogg123 --quiet ' + _filename), stdout=PIPE, stderr=PIPE) _stdout, _stderr = _process.communicate()
def run ( self ): while(not self.done): if(self.main.main.currentArea==self.main.main.PANE_MUSIC and music.get_busy()): self.main.updateScreen(False); pygame.time.delay(500); self.loopDone=True;
def jog_music(): """If no music is currently playing, start playing the next item from the current playlist.""" if music_enabled and not music.get_busy(): start_next_music()
def get_music_status(self): return music.get_busy()
def is_playing(name): """Return True if the music is playing and not paused.""" return _music.get_busy() and not _paused