Commit 95beaf90 by BellCodeEditor

auto save

parent 349f0c91
Showing with 25 additions and 7 deletions
...@@ -12,21 +12,24 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -12,21 +12,24 @@ 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') # 下一曲按钮
my_font = pygame.font.Font('neuropol.ttf', 18)
music_list = [] music_list = []
path = "C:\\Users\\Administrator\\Desktop\\tast" path = "C:\\Users\\HP\\Desktop\\text"
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" or i[-4:] == ".mp3":
music_list.append(i) music_list.append(i)
print(music_list)
volume = 0.2 volume = 0.2
pygame.mixer.music.set_volume(volume) pygame.mixer.music.set_volume(volume)
click = 0 click = 0
play_button = stop_img play_button = stop_img
angle = 0 angle = 0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
print(event)
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
...@@ -81,14 +84,28 @@ while True: ...@@ -81,14 +84,28 @@ while True:
num += 1 num += 1
if num > len(music_list)-1: if num > len(music_list)-1:
num = 0 num = 0
music = pygame.mixer.Sound(path + "\\" + music_list[num])
#music.play()
music_len=int(music.get_length())
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_time = pygame.mixer.music.get_pos()
play_time = play_time//1000
play_m = play_time//60
play_s = play_time%60
info = str(play_m) + ":" +str(play_s)
text = my_font.render(info, True, (0, 0, 0))
#print(info)
new_logo = pygame.transform.rotate(logo_img, angle) new_logo = pygame.transform.rotate(logo_img, angle)
angle += 1 newRect = new_logo.get_rect(center=(320,200))
#print(newRect)
pos = (newRect[0],newRect[1])
if play_button == stop_img:
angle += 1
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(logo_img, (170, 60)) screen.blit(new_logo, pos)
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(text, (45,400))
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