Commit aa464380 by BellCodeEditor

save project

parent b24fbbc1
Showing with 27 additions and 2 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import os
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
...@@ -15,7 +16,13 @@ logo_img = pygame.image.load('logo.png') # 下一曲按钮 ...@@ -15,7 +16,13 @@ logo_img = pygame.image.load('logo.png') # 下一曲按钮
# 载入音乐 # 载入音乐
# 载入音乐 # 载入音乐
a = ['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg'] a = []
path ='C:\\Users\\A\\Desktop\\新建文件夹'
fillist = os.listdir(path)
for i in fillist:
if i[-4:] == '.wav' or i[-4:] == '.ogg':
a.append(i)
num = -1 num = -1
...@@ -55,12 +62,30 @@ while True: ...@@ -55,12 +62,30 @@ while True:
else: else:
play_button = play_img play_button = play_img
pygame.mixer.music.pause() pygame.mixer.music.pause()
if x > 120 and x < 220 and y > 350 and y < 400:
num -= 1
if num < 0:
num = len(a) - 1
pygame.mixer.music.load(path+'\\'+a[num])
pygame.mixer.music.play()
click = 0
play_button = stop_img
if x > 420 and x < 520 and y > 350 and y < 400:
num += 1
if num > len(a) - 1:
num = 0
pygame.mixer.music.load(path+'\\'+a[num])
pygame.mixer.music.play()
click = 1
play_button = stop_img
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
num += 1 num += 1
if num > len(a)-1: if num > len(a)-1:
num = 0 num = 0
pygame.mixer.music.load(a[num]) pygame.mixer.music.load(path+'\\'+a[num])
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