Exemple #1
0
def play(fname, timestamp):
    init(fname)
    while (timestamp - (time.time() + TO_ADD)) > 0:
        pass
    music.unpause()
    while True:
        time.sleep(1)
Exemple #2
0
 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()
Exemple #3
0
 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)
Exemple #5
0
    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)
Exemple #8
0
 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)
Exemple #10
0
 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()
Exemple #11
0
 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)
Exemple #12
0
 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()
Exemple #13
0
    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
Exemple #14
0
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()
Exemple #15
0
    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
Exemple #16
0
 def uppause(self):
     music.unpause()
Exemple #17
0
def resume():
    music.unpause()
Exemple #18
0
def unpause():
    """Resume playback of the music stream after it has been paused."""
    global _paused
    _music.unpause()
    _paused = False
Exemple #19
0
def unpause():
    """Resume playback of the music stream after it has been paused."""
    global _paused
    _music.unpause()
    _paused = False
Exemple #20
0
def unpause(event):
	music.unpause()
	root.bind(settings["shortcuts"]["un_pause"], pause)
Exemple #21
0
def unpause():
    music.unpause()
Exemple #22
0
    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()
Exemple #23
0
 def unpause_click(self):
     music.unpause()
Exemple #24
0
 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()