From fc8197cc308cc914e012cf2e9cc938ec733021ca Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sat, 22 Apr 2023 17:37:53 +0800 Subject: [PATCH] auto save --- my_music.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/my_music.py b/my_music.py index c58a174..2d08bb9 100644 --- a/my_music.py +++ b/my_music.py @@ -30,11 +30,10 @@ while True: if event.type == locals.KEYDOWN: if event.key == locals.K_UP: volume += 0.1 - if volume > 1: - volume = 1 + volume = 1 pygame.mixer.music.set_volume(volume) if event.key == locals.K_DOWN: - volume -= 0.1 + volume -= 0.1 if volume < 0: volume = 0 pygame.mixer.music.set_volume(volume) @@ -55,9 +54,14 @@ while True: num += 1 if num > len(music_list)-1: num = 0 - pygame.mixer.music.load(music_list[num]) + pygame.mixer.music.load(path+"\\"+music_list[num]) pygame.mixer.music.play() - + if pygame.mixer.music.get_busy() == False: + num += 1 + if num > len(music_list)-1: + num = 0 + pygame.mixer.music.load(path+"\\"+music_list[num]) + # 绘制画面 screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(play_button, (270, 330)) # 暂停按钮 @@ -66,3 +70,4 @@ while True: screen.blit(next_img, (420, 350)) # 下一曲 # 刷新画面 pygame.display.update() + \ No newline at end of file -- libgit2 0.25.0