Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson04_diy
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
51413712
authored
Jan 19, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
49d841dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletions
my_music.py
my_music.py
View file @
51413712
...
@@ -12,13 +12,26 @@ last_img = pygame.image.load('last.png') # 上一曲按钮
...
@@ -12,13 +12,26 @@ 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
logo_img
=
pygame
.
image
.
load
(
'logo.png'
)
# 中间logo
#设置音量的初始值volume
volume
=
0.6
#加载音乐文件
#加载音乐文件
pygame
.
mixer
.
music
.
load
(
"歌曲4.ogg"
)
pygame
.
mixer
.
music
.
load
(
"歌曲4.ogg"
)
while
True
:
while
True
:
for
event
in
pygame
.
event
.
get
():
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
#判断事件类型是否为退出事件QUIT????
if
event
.
type
==
locals
.
QUIT
:
#判断事件类型是否为退出事件QUIT????
exit
()
#结束程序
exit
()
#结束程序
if
event
.
type
==
locals
.
KEYDOWN
:
#判断事件类型是否为按键按下事件
if
event
.
key
==
locals
.
K_UP
:
#判断是否按下up键
volume
+=
0.1
#声音加0.1
if
volume
>
1
:
#判断音量是否大于1
volume
=
1
#音量设为1
#设置播放音乐的音量
pygame
.
mixer
.
music
.
set_volume
(
volume
)
#判断是否按下down键
#声音减0.1
#判断音量是否小于0
#音量设为0
#设置播放音乐的音量
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
#判断播放器没有正在播放音乐
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
#判断播放器没有正在播放音乐
pygame
.
mixer
.
music
.
play
()
#播放音乐
pygame
.
mixer
.
music
.
play
()
#播放音乐
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment