Commit fc2db227 by BellCodeEditor

save project

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