Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson5_diy2
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
3b97ccdf
authored
Jun 05, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
022efc42
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
my_music.py
my_music.py
View file @
3b97ccdf
...
...
@@ -3,10 +3,8 @@ from pygame import locals
import
os
pygame
.
init
()
# 初始化
# 创建窗口
screen
=
pygame
.
display
.
set_mode
((
640
,
480
))
# 载入图片、资源
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'
)
# 暂停按钮
...
...
@@ -14,7 +12,6 @@ last_img = pygame.image.load('last.png') # 上一曲按钮
next_img
=
pygame
.
image
.
load
(
'next.png'
)
# 下一曲按钮
logo_img
=
pygame
.
image
.
load
(
'logo.png'
)
# 下一曲按钮
# 载入音乐
pygame
.
mixer
.
music
.
load
(
'歌曲1.wav'
)
pygame
.
mixer
.
music
.
load
(
'歌曲2.wav'
)
pygame
.
mixer
.
music
.
load
(
'歌曲3.wav'
)
...
...
@@ -27,6 +24,7 @@ nu = -1
pygame
.
mixer
.
music
.
set_volume
(
volume
)
# 初始播放音量
click
=
0
play_button
=
stop_img
path
=
str
(
fl
)
while
True
:
for
event
in
pygame
.
event
.
get
():
...
...
@@ -58,6 +56,18 @@ while True:
else
:
play_button
=
play_img
pygame
.
mixer
.
music
.
pause
()
if
x
>
120
and
x
<
220
and
y
>
350
and
y
<
450
:
nu
-=
1
if
nu
<
0
:
un
=
len
(
fl
)
-
1
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
fl
[
nu
])
pygame
.
mixer
.
music
.
play
()
if
x
>
420
and
x
<
520
and
y
>
350
and
y
<
450
:
nu
+=
1
if
nu
>
3
:
un
=
0
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
fl
[
nu
])
pygame
.
mixer
.
music
.
play
()
nu
+=
1
if
nu
>
len
(
fl
)
-
1
:
nu
=
0
...
...
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