def play(fname, timestamp): init(fname) while (timestamp - (time.time() + TO_ADD)) > 0: pass music.unpause() while True: time.sleep(1)
def continue_level(g): g.continue_level() g.player.lives -= 1 g.mode = F_GAME if (g.opt_sfx is True): g.sound_select.play() if (g.opt_music == True): music.unpause()
def play(self, filename: Optional[str] = None) -> None: if filename: self.load(filename) if self.status == Status.stopped: pgmusic.play() self.status = Status.playing elif self.status == Status.paused: pgmusic.unpause() self.status = Status.playing
def start_sound(self): """Включение звука в игре""" music.unpause() for k, v in self.sounds.items(): if k in {'move_on_ground', 'fruit', 'hit', 'potion'}: v.set_volume(0.2) else: v.set_volume(1)
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()
def toggle_pause(self): if not self.playing: self.start_pl() else: if self.paused: music.unpause() else: music.pause() self.paused = not self.paused
def play_menu_music(self): """Проигрывание музыки во время нахождения в меню""" if self.sound: for sound in self.sounds.values(): sound: Sound sound.stop() music.unpause() music.unload() music.load('music/background.mp3') music.set_volume(1) music.play(-1)
def pause(self): channel = self.current_channel paused = self.paused if paused: music.unpause() if channel: channel.unpause() else: music.pause() if channel: channel.pause() self.paused = not paused
def play_game_music(self): """Проигрывание музыки во время нахождения в игре""" if self.sound: for sound in self.sounds.values(): sound: Sound sound.stop() music.unpause() music.unload() music.load('music/background_tango_short.wav') music.set_volume(0.1) music.play(-1)
def pause(self): while True: clock.tick(10) self.play_music() for event in pg.event.get(): if event.type == pg.KEYDOWN: if event.key == pg.K_ESCAPE: music_player.unpause() screen.fill(BLACK) pg.display.flip() return elif event.type == pg.QUIT: pg.quit() quit()
def on_play(self): if self.play.source.split('/')[1] == "play.png": if self.play.started: music.unpause() else: music.load(music_path + self.song.text) music.play() self.play.started = 1 self.play.source = self.play.source.split('/')[0] + "/stop.png" Clock.schedule_interval(self.update, 0.1) else: music.pause() self.play.source = self.play.source.split('/')[0] + "/play.png" Clock.unschedule(self.update)
def switch_sound(g): if (g.opt_music == False): g.opt_music = True if (g.opt_sfx is True): g.sound_on.play() if (g.previous_mode == F_MAIN_MENU): # music.play(-1) music.rewind() music.unpause() # else : else: if (g.opt_sfx is True): g.sound_off.play() g.opt_music = False music.pause()
def _play_button_hit(self): """Method contains actions when play button hit""" if pygame_music.get_pos() == -1: pygame_music.load(self._filepath) current_track = pygame_Sound(self._filepath) self._time_scale['to'] = current_track.get_length() self._play_button['text'] = 'Stop' pygame_music.play() pygame_music.set_pos(float(self._time_scale_var.get())) elif self._paused: self._play_button['text'] = 'Stop' pygame_music.unpause() self._paused = False else: self._play_button['text'] = 'Play' pygame_music.pause() self._paused = True
def play_pause(): global playing if playing == True: mp3.pause() playing = False print("Paused") newlogline("Paused") displayH("pause") elif playing == False: mp3.unpause() playing = True displayCL() displayH("play") else: mp3.load(l[index]) # az első szám betöltése mp3.play() playing = True displayH("play") displayCL()
def general(g, keys): if keys[K_ESCAPE]: sys.exit(0) if (g.mode == F_GAME): g.menu_timer -= g.dt if (g.menu_timer <= 0): if keys[K_m]: if (g.opt_music == False): g.opt_music = True if (g.opt_sfx is True): g.sound_on.play() if ((g.mode != F_GAME and g.previous_mode == F_MAIN_MENU) or g.mode == F_GAME): # music.play(-1) music.rewind() music.unpause() else: if (g.opt_sfx is True): g.sound_off.play() g.opt_music = False music.pause() g.menu_timer = MENU_INPUT_DELAY
def uppause(self): music.unpause()
def resume(): music.unpause()
def unpause(): """Resume playback of the music stream after it has been paused.""" global _paused _music.unpause() _paused = False
def unpause(event): music.unpause() root.bind(settings["shortcuts"]["un_pause"], pause)
def unpause(): music.unpause()
except ValueError: messb.showinfo("输入不是数字", "请输入正确的索引") else: try: c = musfObjl()[t1] b = c a = "编号" + str(t1) + "的歌曲\n" + str(b) + "可以播放" messb.showinfo("正确", a) return t1 except: messb.showinfo("错误", "歌曲不存在") def musObjPlay1(): index = tkObjBcom1() musLp1 = music.load(musfObjl()[index]) music.play(1, 0) tkObjstr1 = tk.Label(mTkObj, text="输入播放音乐").place(x=50, y=0) tkObjSV1 = tk.StringVar() tkObjE = tk.Entry(mTkObj, textvariable=tkObjSV1).place(x=50, y=20) tkObjBut2 = tk.Button(mTkObj, text="播放", command=musObjPlay1).place(x=70, y=40) tkObjBut3 = tk.Button(mTkObj, text="暂停", command=music.pause()).place(x=40, y=100) tkObjBut4 = tk.Button(mTkObj, text="开始", command=music.unpause()).place(x=100, y=100) mTkObj.mainloop()
def unpause_click(self): music.unpause()
def resume_level(g): g.mode = F_GAME if (g.opt_sfx is True): g.sound_select.play() if (g.opt_music == True): music.unpause()