Commit 226dbb66 by BellCodeEditor

save project

parent 9c62416a
import pygame
from pygame import locals
import os
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
# 载入图片、资源
bg_img = pygame.image.load('background.png') # 背景图
play_img = pygame.image.load('play.png') # 播放按钮
stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮
basic_font = pygame.font.Font('neuropol.ttf',14)
#music_list=["Bygone Bumps.mp3","Herobrine's Life.mp3","歌曲4.mp3"]
music_list=[]
path="C:\\Users\\dell\\Desktop\\新建文件夹 (2)"
filelist = os.listdir(path)
music_list = []
for i in filelist:
if i[-4:] ==".mp3" or i[-4:]==".ogg" or i[-4:]==".wav":
music_list.append(i)
num = -1
volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0
play_button = stop_img
angle = 0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
# 按键,控制声音大小
if event.type == locals.KEYDOWN:
if event.key == locals.K_UP:
volume += 0.1
if volume > 1:
volume = 1
pygame.mixer.music.set_volume(volume)
if event.key == locals.K_DOWN:
volume -= 0.1
if volume < 0:
volume = 0
pygame.mixer.music.set_volume(volume)
# 按下鼠标
if event.type == locals.MOUSEBUTTONDOWN:
if event.button == 1:
x, y = event.pos
if x > 270 and x < 370 and y > 350 and y < 450:
# 次数增加
click += 1
if click % 2 == 0:
play_button = stop_img
pygame.mixer.music.unpause()
else:
play_button = play_img
pygame.mixer.music.pause()
if x > 120 and x < 220 and y > 350 and y < 400:
num -= 1
if num < 0:
num = len(music_list) - 1
pygame.mixer.music.load(path+"\\"+music_list[num])
pygame.mixer.music.play()
play_button=stop_img
click = 0
music1 = pygame.mixer.Sound(path + "\\" + music_list[num])
music_length = music1.get_length()
music_length = int(music_length)
if x > 420 and x < 520 and y > 350 and y < 400:
num += 1
if num > len(music_list)-1:
num = 0
pygame.mixer,music,load(path +"\\" +music_list[num])
pygame.mixer,music.play()
play_button = stop_imp
click = 0
music1 = pygame.mixer.Sound(path + "\\" + music_list[num])
music_length = music1.get_length()
music_length = int(music_length)
if pygame.mixer.music.get_busy() == False:
num += 1
if num>len(music_list)-1:
num=0
pygame.mixer.music.load(path+ "\\" +music_list[num])
pygame.mixer.music.play()
music1 = pygame.mixer.Sound(path + "\\" + music_list[num])
music_length = music1.get_length()
music_length = int(music_length)
play_time = pygame.mixer.music.get_pos()
play_time = int(play_time/1000)
play_m = play_time//60
play_s = play_time % 60
info = str(play_m) + ":" + str(play_s)
music_m = music_length//60
music_s = music_length%60
info2 = str(music_m)+":"+str(music_s)
new_logo = pygame.transform.rotate(logo_img, angle)
newRect = new_logo.get_rect(center=(320, 200))
pos = (newRect[0], newRect[1])
if play_button == stop_img:
angle += 1
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
screen.blit(new_logo, pos) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲
scoreSurf = basic_font.render(info, True, (255, 255, 255))
screen.blit(scoreSurf, (120,440))
scoreSurf2 = basic_font.render("/" + info2, True, (0, 0, 0))
screen.blit(scoreSurf2, (170,440))
# 刷新画面
pygame.display.update()
last.png

3.79 KB

import pygame
from pygame import locals
import os
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
# 载入图片、资源
bg_img = pygame.image.load('background.png') # 背景图
play_img = pygame.image.load('play.png') # 播放按钮
stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮
# 音乐
music_list = []
path = "C:\\Users\\bellcode\\Desktop\\test"
filelist = os.listdir(path)
for i in filelist:
if i[-4:] == ".ogg" or i[-4:] == ".wav":
music_list.append(i)
num = -1
volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0
play_button = stop_img
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
# 按键,控制声音大小
if event.type == locals.KEYDOWN:
if event.key == locals.K_UP:
volume += 0.1
if volume > 1:
volume = 1
pygame.mixer.music.set_volume(volume)
if event.key == locals.K_DOWN:
volume -= 0.1
if volume < 0:
volume = 0
pygame.mixer.music.set_volume(volume)
if event.type == locals.MOUSEBUTTONDOWN:
if event.button == 1: # 左击
x, y = event.pos
if x > 270 and x < 370 and y > 350 and y < 450:
click += 1
if click % 2 == 0:
play_button = stop_img
pygame.mixer.music.unpause()
else:
play_button = play_img
pygame.mixer.music.pause()
if x > 120 and x < 220 and y > 350 and y < 400: #上一曲
num -= 1
if num < 0:
num = len(music_list) - 1
pygame.mixer.music.load(path +"\\" +music_list[num])
pygame.mixer.music.play()
play_button = stop_img
click = 0
if x > 420 and x < 520 and y > 350 and y < 400: #下一曲
num += 1
if num > len(music_list)-1:
num = 0
pygame.mixer.music.load(path +"\\" +music_list[num])
pygame.mixer.music.play()
play_button = stop_img
click = 0
if pygame.mixer.music.get_busy() == False:
num += 1
if num > len(filelist)-1:
num = 0
print(num)
pygame.mixer.music.load(path + "\\"+music_list[num])
pygame.mixer.music.play()
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
screen.blit(logo_img, (170, 60)) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲
# 刷新画面
pygame.display.update()
\ No newline at end of file
logo.png

40.9 KB

File added
next.png

3.87 KB

play.png

12.1 KB

stop.png

11.6 KB

File added
File added
File added
File added
File added
[00:00.00] 词:任天宇/刘家泽
[00:00.00] 词:任天宇/刘家泽
[00:01.00] 曲:任天宇
[00:02.00] 制作人:任天宇
[00:03.00] Remix:梨云
[00:04.00] 混音:任天宇
[00:05.00] 和声:任天宇/宽大叔窄大叔/野王妲己
[00:06.00] 录音:安羽辰
[00:07.00] 统筹:晓悠
[00:08.00] 封面:灭害灵
[00:09.00] 监制:刘家泽/任天宇
[00:10.00] 发行:冯昌榆
[00:11.00] 出品:刘家泽
[00:12.00] 制作公司:匠心音乐/梨云音乐社
[00:13.00] OP:匠心音乐
[00:16.92]每次努力回头望
[00:19.65]那姑娘在远方
[00:24.84]总会想来日方长
[00:27.63]梦一场去流浪
[00:33.00]
[00:33.03]生活给我一身伤
[00:35.67]或惆怅或迷惘
[00:40.86]念念不忘的姑娘
[00:43.65]在心上在远方
[00:47.40]
[00:48.36]抬头看看那曾经的夕阳
[00:52.11]落在我的肩上那时心之所向
[00:56.79]那些曾经努力后的失望
[01:00.09]是青春的倔强是情深一往
[01:03.48]
[01:06.21]我不慌星光就在前方
[01:09.42]别再驻足眺望背上我的行囊
[01:14.13]就疯狂答案都在路上
[01:17.43]风在自由歌唱翻山越岭飞翔
[01:22.17]
[01:22.23]我不慌梦想就在前方
[01:25.44]带上心爱姑娘明天就到远方
[01:30.12]手不放紧跟梦的方向
[01:33.42]梦中就有希望也许就在身旁满目星光
[01:57.00]
[01:57.03]生活给我一身伤
[01:59.67]或惆怅或迷惘
[02:04.86]念念不忘的姑娘
[02:07.68]在心上在远方
[02:11.40]
[02:12.36]抬头看看那曾经的夕阳
[02:16.11]落在我的肩上那时心之所向
[02:20.82]那些曾经努力后的失望
[02:24.09]是青春的倔强是情深一往
[02:39.51]
[02:44.19]我不慌星光就在前方
[03:05.43]别再驻足眺望背上我的行囊
[03:10.14]就疯狂答案都在路上
[03:13.44]风在自由歌唱翻山越岭飞翔
[03:18.06]
[03:18.21]我不慌梦想就在前方
[03:21.42]带上心爱姑娘明天就到远方
[03:26.13]手不放紧跟梦的方向
[03:29.43]梦中就有希望也许就在身旁满目星光
[03:37.17]
[03:44.97]每次努力回头望
[03:47.70]那姑娘在远方
File added
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