Commit 349d2ac8 by BellCodeEditor

save project

parent a4cfcd47
Showing with 9 additions and 6 deletions
import pygame
from pygame import locals
import os
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
......@@ -12,9 +12,12 @@ last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 中间logo
pygame.mixer.music.load('歌曲4.ogg')
filelist = []
path = 'C:\\Users\\HP\\Desktop\\test'
files = os.listdir(path)
for i in files:
if i[-4:] =='.wav' or i[-4:] =='.ogg' or i[-4:] =='.mp3':
filelist.append(i)
volume = 0.2
pygame.mixer.music.set_volume(volume)
num = -1
......@@ -51,9 +54,9 @@ while True:
volume = 0
if pygame.mixer.music.get_busy() == False:
num+=1
if num>len(music_list)-1:
if num>len(filelist)-1:
num = 0
pygame.mixer.music.locals(music_list(num))
pygame.mixer.music.load(path+'\\'+filelist[num])
pygame.mixer.music.play()
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
......
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