Commit 16060cc4 by BellCodeEditor

save project

parent 606282fa
Showing with 13 additions and 2 deletions
import os
f=os.listdir('C:\\Users\\Administrator\\Desktop\\music')
print(f)
\ No newline at end of file
import pygame
from pygame import locals
import os
pygame.init() # 初始化
# 创建窗口
......@@ -13,7 +14,13 @@ next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮
# 载入音乐
f = ['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg']
m_l = []
th = 'C:\\Users\\Administrator\\Desktop\\music'
f = os.listdir(th)
for i in f:
if i[-4:] == '.ogg' or i[-4:] == '.wav':
m_l.append(i)
n = -1
volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量
......@@ -55,7 +62,7 @@ while True:
n+=1
if n > len(f)-1:
n=0
pygame.mixer.music.load(f[n])
pygame.mixer.music.load(th + '\\' + m_l[n])
pygame.mixer.music.play()
......
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