Commit 6f1ac5e3 by BellCodeEditor

auto save

parent 7de0de9a
Showing with 21 additions and 4 deletions
......@@ -11,7 +11,6 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮
# 载入音乐
# 载入音乐
music_lest=['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg']
......@@ -20,14 +19,11 @@ filelist = os.listdir(path)
for file in filelist:
if file[-4:] == ".wav" or file[-4:]==".ogg":
music_lest.append(file)
num=-1
volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0
play_button = stop_img
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -43,6 +39,19 @@ while True:
volume -= 0.1
if volume < 0:
volume = 0
exit()
# 按键,控制声音大小
if event.type == locals.KEYDOWN:
if event.key == locals.K_UP:
volume += 0.1
if volume > 1:
volume = 1
pygame.mixer.music.set_volume(volume)
if event.key == locals.K_DOWN:
volume -= 0.1
if volume < 0:
volume = 0
pygame.mixer.music.set_volume(volume)
# 按下鼠标
......@@ -58,6 +67,10 @@ while True:
else:
play_button = play_img
pygame.mixer.music.pause()
if pygame.mixer.music.get_busy() == False:
num += 1
......@@ -66,6 +79,10 @@ while True:
pygame.mixer.music.load(path+"\\"+music_lest[num])
pygame.mixer.music.play()
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment