Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson4_diy3
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
c4a91d4a
authored
2 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
23337858
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
my_music.py
my_music.py
View file @
c4a91d4a
import
pygame
from
pygame
import
locals
import
os
pygame
.
init
()
# 初始化
# 创建窗口
...
...
@@ -11,9 +12,19 @@ play_img = pygame.image.load('play.png')
stop_img
=
pygame
.
image
.
load
(
'stop.png'
)
next_img
=
pygame
.
image
.
load
(
'next.png'
)
# 背景图
logo_img
=
pygame
.
image
.
load
(
'logo.png'
)
pygame
.
mixer
.
music
.
load
(
'歌曲1.wav'
)
volume
=
0.8
music_list
=
[]
path
=
"C:
\
Users
\a
dmin
\
Documents
\
pygame_lesson4_diy3"
filelist
=
os
.
listdir
(
path
)
for
i
in
filelist
:
if
i
[
-
4
:]
==
".ogg"
or
i
[
-
4
:]
==
".wav"
:
music_list
.
append
(
i
)
num
=
-
1
volume
=
0.6
pygame
.
mixer
.
music
.
set_volume
(
volume
)
c
=
0
stop
=
stop_img
while
True
:
for
event
in
pygame
.
event
.
get
():
...
...
@@ -30,6 +41,14 @@ while True:
if
volume
<
0
:
volume
=
0
pygame
.
mixer
.
music
.
set_volume
(
volume
)
if
event
.
type
==
locals
.
MOUSEBUTTONDOWN
:
c
+=
1
if
c
%
2
==
0
:
stop
=
stop_img
pygame
.
mixer
.
music
.
unpause
()
else
:
stop
=
play_img
pygame
.
mixer
.
music
.
pause
()
...
...
@@ -40,7 +59,7 @@ while True:
# 绘制画面
screen
.
blit
(
bg_img
,
(
0
,
0
))
screen
.
blit
(
stop
_img
,
(
270
,
330
))
screen
.
blit
(
stop
,
(
270
,
330
))
screen
.
blit
(
logo_img
,
(
170
,
60
))
screen
.
blit
(
last_img
,
(
120
,
350
))
screen
.
blit
(
next_img
,
(
420
,
350
))
# 填充背景
...
...
This diff is collapsed.
Click to expand it.
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