Commit 65c9ff00 by BellCodeEditor

save project

parent 7291a32c
Showing with 38 additions and 11 deletions
...@@ -12,11 +12,13 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -12,11 +12,13 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮 last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮 next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮 logo_img = pygame.image.load('logo.png') # 下一曲按钮
Font = pygame.font.Font('neuropol.ttf',14)
music_list = [] music_list = []
path = "C:\\Users\\Administrator\\Desktop\\text" path = R"C:\Users\Administrator\Desktop\test"
filelist = os.listdir(path) filelist = os.listdir(path)
num = -1 num = -1
for i in filelist: for i in filelist:
if i[-4:] == ".wav" or i[-4:] == ".ogg": if i[-4:] == ".wav" or i[-4:] == ".ogg":
music_list.append(i) music_list.append(i)
...@@ -27,6 +29,8 @@ play_button = stop_img ...@@ -27,6 +29,8 @@ play_button = stop_img
angle = 0 angle = 0
music = None
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -62,10 +66,9 @@ while True: ...@@ -62,10 +66,9 @@ while True:
pygame.mixer.music.load(path + "\\" + music_list[num]) pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play() pygame.mixer.music.play()
play_button = stop_img play_button = stop_img
if click % 2 == 0: click = 0
click += 2 music = pygame.mixer.Sound(path + "\\" + music_list[num])
else: music_len = int(music.get_length())
click += 1
if x > 120 and x < 220 and y > 350 and y < 400: # 上一曲 if x > 120 and x < 220 and y > 350 and y < 400: # 上一曲
num -= 1 num -= 1
...@@ -74,10 +77,9 @@ while True: ...@@ -74,10 +77,9 @@ while True:
pygame.mixer.music.load(path + "\\" + music_list[num]) pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play() pygame.mixer.music.play()
play_button = stop_img play_button = stop_img
if click % 2 == 0: click = 0
click += 2 music = pygame.mixer.Sound(path + "\\" + music_list[num])
else: music_len = int(music.get_length())
click += 1
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
num += 1 num += 1
...@@ -85,15 +87,40 @@ while True: ...@@ -85,15 +87,40 @@ while True:
num = 0 num = 0
pygame.mixer.music.load(path + "\\" + music_list[num]) pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play() pygame.mixer.music.play()
music = pygame.mixer.Sound(path + "\\" + music_list[num])
music_len = int(music.get_length())
play_time = int(pygame.mixer.music.get_pos()/1000)
play_m = play_time // 60
play_s = play_time % 60
if play_s < 10:
play_s = "0" + str(play_s)
info2 = str(play_m) + ":" + str(play_s)
music_m = music_len // 60
music_s = music_len % 60
if music_s < 10:
music_s = "0" + str(music_s)
info3 = str(music_m) + ":" + str(music_s)
info = info2 + " / " + info3
new_logo = pygame.transform.rotate(logo_img,angle) new_logo = pygame.transform.rotate(logo_img,angle)
newRect = new_logo.get_rect(center=(320,200)) newRect = new_logo.get_rect(center=(320,200))
pos = (newRect[0],newRect[1]) pos = (newRect[0],newRect[1])
angle += 1 angle += 1
timeSurf = Font.render(info,True,(13,233,22))
# 绘制画面 # 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮 screen.blit(play_button, (270, 330)) # 暂停按钮
screen.blit(new_logo,pos) # 中间logo图 screen.blit(new_logo,pos) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲 screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲 screen.blit(next_img, (420, 350)) # 下一曲
screen.blit(timeSurf,(120,440))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
\ No newline at end of file
\ 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