Commit 026640db by BellCodeEditor

auto save

parent a9540bad
Showing with 30 additions and 2 deletions
...@@ -12,7 +12,8 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -12,7 +12,8 @@ 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') # 下一曲按钮
#加载字体basic_font
basic_font=pygame.font.Font("neuropol.ttf",14)
music_list = ['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg'] music_list = ['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg']
# path = "C:\\Users\\bellcode\\Desktop\\test" # path = "C:\\Users\\bellcode\\Desktop\\test"
# filelist = os.listdir(path) # filelist = os.listdir(path)
...@@ -59,6 +60,9 @@ while True: ...@@ -59,6 +60,9 @@ while True:
num = 0 num = 0
pygame.mixer.music.load(music_list[num]) pygame.mixer.music.load(music_list[num])
pygame.mixer.music.play() pygame.mixer.music.play()
music1=pygame.mixer.Sound(music_list[num]) #歌曲时间使用Sound方法加载音乐music1
music_length=music1.get_length()#获取歌曲的播放时长music_length
music_length=int(music_length)#取整
play_button = stop_img play_button = stop_img
if click % 2 == 0: if click % 2 == 0:
click += 2 click += 2
...@@ -71,6 +75,9 @@ while True: ...@@ -71,6 +75,9 @@ while True:
num = len(music_list) - 1 num = len(music_list) - 1
pygame.mixer.music.load(music_list[num]) pygame.mixer.music.load(music_list[num])
pygame.mixer.music.play() pygame.mixer.music.play()
music1=pygame.mixer.Sound(music_list[num]) #歌曲时间使用Sound方法加载音乐music1
music_length=music1.get_length()#获取歌曲的播放时长music_length
music_length=int(music_length)#取整
play_button = stop_img play_button = stop_img
if click % 2 == 0: if click % 2 == 0:
click += 2 click += 2
...@@ -83,11 +90,25 @@ while True: ...@@ -83,11 +90,25 @@ while True:
num = 0 num = 0
pygame.mixer.music.load( music_list[num]) pygame.mixer.music.load( music_list[num])
pygame.mixer.music.play() pygame.mixer.music.play()
music1=pygame.mixer.Sound(music_list[num]) #歌曲时间使用Sound方法加载音乐music1
music_length=music1.get_length()#获取歌曲的播放时长music_length
music_length=int(music_length)#取整
play_time=pygame.mixer.music.get_pos() #获取歌曲播放进度的时间play_time
play_time=int(play_time/1000)#转换为整秒
time_m=play_time//60#几分
time_s=play_time%60#几秒
info=str(time_m)+":"+str(time_s) #以“?分:?秒”的形式表示出时间进度
#歌曲的时间长度
music_m=music_length//60
music_s=music_length%60
if music_s<10:#如果时间秒数少于10
music_s="0"+str(music_s)
info2=str(music_m)+":"+str(music_s)
new_logo=pygame.transform.rotate(logo_img,angle)#使用一个新的变量new_logo存储旋转后的图片 new_logo=pygame.transform.rotate(logo_img,angle)#使用一个新的变量new_logo存储旋转后的图片
new_Rect=new_logo.get_rect(center=(320,200))#校正旋转图片的中心点 new_Rect=new_logo.get_rect(center=(320,200))#校正旋转图片的中心点
pos=(new_Rect[0],new_Rect[1]) pos=(new_Rect[0],new_Rect[1])
if play_button==stop_img: if play_button==stop_img:
+9angle+=1 angle+=1
# 绘制画面 # 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
...@@ -95,5 +116,11 @@ while True: ...@@ -95,5 +116,11 @@ while True:
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)) # 下一曲
#绘制时间进度scoresurf
scoresurf=basic_font.render(info,True,(255,255,255))
screen.blit(scoresurf,(120,440))
scoresurf2=basic_font.render("/"+info2,True,(0,0,0))
screen.blit(scoresurf,(170,440))
# 刷新画面 # 刷新画面
pygame.display.update() 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