Commit bcc739de by BellCodeEditor

save project

parent d1fc6085
Showing with 22 additions and 2 deletions
...@@ -2,6 +2,7 @@ import pygame ...@@ -2,6 +2,7 @@ import pygame
from pygame import locals from pygame import locals
import os import os
angle=1 angle=1
music_length=0
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
...@@ -68,7 +69,10 @@ while True: ...@@ -68,7 +69,10 @@ while True:
click += 2 click += 2
else: else:
click += 1 click += 1
music1=pygame.mixer.Sound(path + "\\" + music_list[num])
music_length=music1.get_length()
music_length=int(music_length)
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
if num < 0: if num < 0:
...@@ -81,19 +85,33 @@ while True: ...@@ -81,19 +85,33 @@ while True:
else: else:
click += 1 click += 1
music1=pygame.mixer.Sound(path + "\\" + music_list[num])
music_length=music1.get_Length()
music_length=int(music_length)
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
num += 1 num += 1
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()
music1=pygame.mixer.Sound(path + "\\" + music_list[num])
music_length=music1.get_length()
music_length=int(music_length)
# 播放时间 # 播放时间
play_time=pygame.mixer.music.get_pos() play_time=pygame.mixer.music.get_pos()
play_time=play_time//1000 play_time=play_time//1000
play_m=play_time//60 play_m=play_time//60
play_s=play_time%60 play_s=play_time%60
play_q=str(play_m)+":"+str(play_s) play_q=str(play_m)+":"+str(play_s)
music_lengthm=music_length//60
music_lengths=music_length%60
music_lengthq="/"+str(music_lengthm)+":"+str(music_lengths)
font_content=font.render(play_q,True,(250,250,250)) font_content=font.render(play_q,True,(250,250,250))
music_content=font.render(music_lengthq,True,(250,250,250))
# 旋转图片play_q, # 旋转图片play_q,
new_logo=pygame.transform.rotate(logo_img,angle) new_logo=pygame.transform.rotate(logo_img,angle)
...@@ -107,6 +125,7 @@ while True: ...@@ -107,6 +125,7 @@ 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)) # 下一曲
screen.blit(font_content, (200, 200)) screen.blit(font_content, (120, 440))
screen.blit(music_content, (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