Commit 1a145fb6 by BellCodeEditor

save project

parent d3e06c2c
Showing with 10 additions and 3 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import os
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
...@@ -11,10 +12,16 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -11,10 +12,16 @@ 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') # 下一曲按钮
m_list = ['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg'] m_list = []
path = r'C:\Users\Administrator\Desktop\新建文件夹 (2)'
filelist = os.listdir(path)
for file in filelist:
if file[-4:] == '.ogg' or file[-4:] == '.wav':
m_list.append(file)
print(m_list)
# 载入音乐 # 载入音乐
num = 0 num = 0
volume = 0.2 volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量 pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0 click = 0
...@@ -52,7 +59,7 @@ while True: ...@@ -52,7 +59,7 @@ while True:
pygame.mixer.music.pause() pygame.mixer.music.pause()
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
pygame.mixer.music.load(m_list[num]) pygame.mixer.music.load(path+'\\'+m_list[num])
num += 1 # 载入音乐 num += 1 # 载入音乐
if num > len(m_list)-1: if num > len(m_list)-1:
num = 0 num = 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