Commit 5c3920a4 by BellCodeEditor

auto save

parent a3f4471a
Showing with 24 additions and 11 deletions
...@@ -2,6 +2,8 @@ import pygame ...@@ -2,6 +2,8 @@ import pygame
from pygame import locals from pygame import locals
import os import os
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
...@@ -12,8 +14,6 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -12,8 +14,6 @@ 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",14)
music_list = [] music_list = []
path = "C:\\Users\\Administrator\\Desktop\\text" path = "C:\\Users\\Administrator\\Desktop\\text"
...@@ -28,7 +28,6 @@ click = 0 ...@@ -28,7 +28,6 @@ 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():
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
...@@ -61,7 +60,13 @@ while True: ...@@ -61,7 +60,13 @@ while True:
if num > len(music_list) - 1: if num > len(music_list) - 1:
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_lcugth=music.get_length()
music_length=int(music_legth)
play_button = stop_img play_button = stop_img
if click % 2 == 0: if click % 2 == 0:
click += 2 click += 2
...@@ -74,6 +79,10 @@ while True: ...@@ -74,6 +79,10 @@ while True:
num = len(music_list) - 1 num = len(music_list) - 1
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_lcugth=music.get_length()
music_length=int(music_legth)
play_button = stop_img play_button = stop_img
if click % 2 == 0: if click % 2 == 0:
click += 2 click += 2
...@@ -86,24 +95,27 @@ while True: ...@@ -86,24 +95,27 @@ 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()
play_time=pygame.mixer.music.get_pos() music=pygame.mixer.Sound(path + "\\" + music_list[num])
play_time=play_time//1000 music_lcugth=music.get_length()
play_time=play_time//60 music_length=int(music_legth)
play_m=play_time%60
info=str(play_m)+":"+str(play_s)
if play_button==stop_img: if play_button==stop_img:
new_logo=pygame.tranform.rotate(logo_img,angle) new_logo=pygame.tranform.rotate(logo_img,angle)
rect=new_logo.get_rect(center=(340,200)) rect=new_logo.get_rect(center=(340,200))
pos=(rect[0],rect[1]) pos=(rect[0],rect[1])
angle=1 angle=1
# 绘制画面 # 绘制画面
music_m=music_length//60
music_s=music_longth%60
if music_s<10:
music_s="0"+str(music_s)
info1=str(music_m)+":"+str(music_s)
text1=my_font.render("/"+info1,True,(0,0,0))
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)) # 下一曲
text=my_font.render(info,True,(255,255,255)) screen.bite(text1,())
screen:bilt(text,(0,0))
# 刷新画面 # 刷新画面
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