Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson5_diy1
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
498b63a7
authored
Apr 05, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
24e14683
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
12 deletions
my_music.py
my_music.py
View file @
498b63a7
import
pygame
import
os
from
pygame
import
locals
pygame
.
init
()
# 初始化
...
...
@@ -14,10 +15,16 @@ logo_img = pygame.image.load('logo.png') # 下一曲按钮
volume
=
0.2
pygame
.
mixer
.
music
.
set_volume
(
volume
)
# 初始播放音量
click
=
0
click
=
1
play_button
=
stop_img
music_list
=
[
"歌曲1.wav"
,
"全素妍.mp3"
,
"植松伸夫.mp3"
,
"Dmitri.mp3"
]
path
=
"C:
\\
Users
\\
ColaMaster
\\
Music
\\
"
temp_list
=
os
.
listdir
(
path
)
music_list
=
[]
for
i
in
temp_list
:
if
i
[
-
4
:]
==
".mp3"
:
music_list
.
append
(
i
)
print
(
music_list
)
num
=
0
while
True
:
for
event
in
pygame
.
event
.
get
():
...
...
@@ -42,17 +49,29 @@ while True:
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
()
click
=
0
-
click
if
x
>
120
and
x
<
220
and
y
>
350
and
y
<
400
:
click
=
1
num
-=
1
if
num
<
0
:
num
=
len
(
music_list
)
-
1
pygame
.
mixer
.
music
.
load
(
path
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
if
x
>
420
and
x
<
520
and
y
>
350
and
y
<
400
:
click
=
1
num
=
(
num
+
1
)
%
3
pygame
.
mixer
.
music
.
load
(
path
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
if
click
==
1
:
play_button
=
stop_img
pygame
.
mixer
.
music
.
unpause
()
else
:
play_button
=
play_img
pygame
.
mixer
.
music
.
pause
()
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
num
=
(
num
+
1
)
%
4
pygame
.
mixer
.
music
.
load
(
music_list
[
num
])
num
=
(
num
+
1
)
%
3
pygame
.
mixer
.
music
.
load
(
path
+
music_list
[
num
])
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