Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson6_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
7de47468
authored
Feb 26, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
aebaa73b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
my_music.py
my_music.py
View file @
7de47468
...
@@ -11,19 +11,24 @@ play_img = pygame.image.load('play.png') # 播放按钮
...
@@ -11,19 +11,24 @@ play_img = pygame.image.load('play.png') # 播放按钮
stop_img
=
pygame
.
image
.
load
(
'stop.png'
)
# 暂停按钮
stop_img
=
pygame
.
image
.
load
(
'stop.png'
)
# 暂停按钮
last_img
=
pygame
.
image
.
load
(
'last.png'
)
# 上一曲按钮
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_img
=
pygame
.
image
.
load
(
'logo.png'
)
#
播放盘
按钮
music_list
=
[]
music_list
=
[]
path
=
"C:
\\
Users
\\
bellcode
\\
Desktop
\\
test
"
path
=
"C:
\\
Users
\\
70471
\\
Desktop
\\
pygame_music
"
filelist
=
os
.
listdir
(
path
)
filelist
=
os
.
listdir
(
path
)
num
=
-
1
num
=
-
1
for
i
in
filelist
:
for
i
in
filelist
:
if
i
[
-
4
:]
==
".wav"
or
i
[
-
4
:]
==
".ogg"
:
if
i
[
-
4
:]
==
".wav"
or
i
[
-
4
:]
==
".ogg"
or
i
[
-
4
:]
==
".mp3"
or
i
[
-
5
:]
==
".flac"
:
music_list
.
append
(
i
)
music_list
.
append
(
i
)
print
(
music_list
)
volume
=
0.2
volume
=
0.2
pygame
.
mixer
.
music
.
set_volume
(
volume
)
# 初始播放音量
pygame
.
mixer
.
music
.
set_volume
(
volume
)
# 初始播放音量
click
=
0
click
=
0
play_button
=
stop_img
play_button
=
stop_img
logo_angle
=
0
rotate_click
=
"roll_on"
my_font
=
pygame
.
font
.
SysFont
(
"neuropol.ttf"
,
50
)
while
True
:
while
True
:
for
event
in
pygame
.
event
.
get
():
for
event
in
pygame
.
event
.
get
():
...
@@ -50,6 +55,7 @@ while True:
...
@@ -50,6 +55,7 @@ while True:
if
click
%
2
==
0
:
if
click
%
2
==
0
:
play_button
=
stop_img
play_button
=
stop_img
pygame
.
mixer
.
music
.
unpause
()
pygame
.
mixer
.
music
.
unpause
()
else
:
else
:
play_button
=
play_img
play_button
=
play_img
pygame
.
mixer
.
music
.
pause
()
pygame
.
mixer
.
music
.
pause
()
...
@@ -84,11 +90,25 @@ while True:
...
@@ -84,11 +90,25 @@ while True:
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
play
()
music_time
=
pygame
.
mixer
.
music
.
get_pos
()
//
1000
time_m
=
music_time
//
60
time_s
=
music_time
%
60
text
=
my_font
.
render
(
str
(
time_m
)
+
":"
+
str
(
time_s
),
True
,(
0
,
255
,
0
))
logo_rotate
=
pygame
.
transform
.
rotate
(
logo_img
,
logo_angle
)
logo_rect
=
logo_rotate
.
get_rect
(
center
=
(
320
,
180
))
pos
=
(
logo_rect
[
0
],
logo_rect
[
1
])
if
play_button
==
stop_img
:
logo_angle
-=
1
# 绘制画面
# 绘制画面
screen
.
blit
(
bg_img
,
(
0
,
0
))
# 填充背景
screen
.
blit
(
bg_img
,
(
0
,
0
))
# 填充背景
screen
.
blit
(
play_button
,
(
270
,
330
))
# 暂停按钮
screen
.
blit
(
play_button
,
(
270
,
330
))
# 暂停按钮
screen
.
blit
(
logo_
img
,
(
170
,
60
)
)
# 中间logo图
screen
.
blit
(
logo_
rotate
,
pos
)
# 中间logo图
screen
.
blit
(
last_img
,
(
120
,
350
))
# 上一曲
screen
.
blit
(
last_img
,
(
120
,
350
))
# 上一曲
screen
.
blit
(
next_img
,
(
420
,
350
))
# 下一曲
screen
.
blit
(
next_img
,
(
420
,
350
))
# 下一曲
screen
.
blit
(
text
,(
120
,
250
))
# 刷新画面
# 刷新画面
pygame
.
display
.
update
()
pygame
.
display
.
update
()
\ No newline at end of file
#FPS.tick(60)
\ No newline at end of file
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