Commit 11c2810a by BellCodeEditor

auto save

parent a78353ea
Showing with 29 additions and 12 deletions
......@@ -14,7 +14,7 @@ next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮
word=pygame.font.Font("neuropol.ttf",18)
music_list = []
path = "C:\\Users\\student\\Desktop\\0"
path = "C:\\Users\\student\\Desktop\\w"
filelist = os.listdir(path)
num = -1
for i in filelist:
......@@ -45,7 +45,7 @@ while True:
pygame.mixer.music.set_volume(volume)
if event.type == locals.MOUSEBUTTONDOWN:
if event.button == 1: # 左击
if event.button == 1: # 左(
x, y = event.pos
if x > 270 and x < 370 and y > 350 and y < 450: # 播放按钮
click += 1
......@@ -55,17 +55,19 @@ while True:
else:
play_button = play_img
pygame.mixer.music.pause()
if x > 420 and x < 520 and y > 350 and y < 400: # 下一曲
num += 1
if num > len(music_list) - 1:
num = 0
pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play()
play_button = stop_img
if click % 2 == 0:
click += 2
else:
click += 1
music1=pygame.mixer.Sound(path+"\\"+music_list[num])
ml=music1.get_length()
ml=int(ml)
if x > 120 and x < 220 and y > 350 and y < 400: # 上一曲
num -= 1
......@@ -78,6 +80,9 @@ while True:
click += 2
else:
click += 1
music1=pygame.mixer.Sound(path+"\\"+music_list[num])
ml=music1.get_length()
ml=int(ml)
if pygame.mixer.music.get_busy() == False:
num += 1
......@@ -85,6 +90,9 @@ while True:
num = 0
pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play()
music1=pygame.mixer.Sound(path+"\\"+music_list[num])
ml=music1.get_length()
ml=int(ml)
play_time=pygame.mixer.music.get_pos()
play_time=int(play_time/1000)
play_m=play_time//60
......@@ -92,20 +100,28 @@ while True:
if play_s<10:
play_s='0'+str(play_s)
info=str(play_m)+':'+str(play_s)
info=word.render(info,True,(0,0,0))
music_m=ml//60
music_s=ml%60
if music_s<10:
music_s='0'+str(music_s)
info1=str(music_m)+':'+str(music_s)
new_logo=pygame.transform.rotate(logo_img,angle)
newRect=new_logo.get_rect(center=(320,200))
pos=(newRect[0],newRect[1])
if play_button==stop_img:
angle+=1
angle+=1
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330))
# 暂停按钮
screen.blit(new_logo, pos) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲
screen.blit(info,(120,450))
screen.blit(next_img, (420, 350)) # 下一曲
t=word.render(info,True,(255,255,255))
screen.blit(t,(120,450))
music_content=word.render('/'+info1,True,(0,0,0))
screen.blit(music_content,(180,450))
# 刷新画面
pygame.display.update()
\ No newline at end of file
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