Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson6_diy4
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
76445293
authored
3 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
078d96f0
c203835l1384p256a14207/wx637248
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
my_music.py
my_music.py
View file @
76445293
...
...
@@ -14,7 +14,7 @@ next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img
=
pygame
.
image
.
load
(
'logo.png'
)
# 下一曲按钮
b_f
=
pygame
.
font
.
Font
(
'neuropol.ttf'
,
14
)
music_list
=
[]
path
=
"C:
\\
Users
\\
Administrator
\\
Desktop
\\
te
s
t"
path
=
"C:
\\
Users
\\
Administrator
\\
Desktop
\\
te
x
t"
filelist
=
os
.
listdir
(
path
)
num
=
-
1
angle
=
0
...
...
@@ -25,7 +25,7 @@ volume = 0.2
pygame
.
mixer
.
music
.
set_volume
(
volume
)
# 初始播放音量
click
=
0
play_button
=
stop_img
music_length
=
0
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
...
...
@@ -65,7 +65,9 @@ while True:
click
+=
2
else
:
click
+=
1
music1
=
pygame
.
mixer
.
Sound
(
path
+
'
\\
'
+
music_list
[
num
])
music_length
=
music1
.
get_length
()
music_length
=
len
(
music_length
)
if
x
>
120
and
x
<
220
and
y
>
350
and
y
<
400
:
# 上一曲
num
-=
1
if
num
<
0
:
...
...
@@ -77,7 +79,9 @@ while True:
click
+=
2
else
:
click
+=
1
music1
=
pygame
.
mixer
.
Sound
(
path
+
'
\\
'
+
music_list
[
num
])
music_length
=
music1
.
get_length
()
music_length
=
len
(
music_length
)
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
num
+=
1
...
...
@@ -88,7 +92,16 @@ while True:
play_time
=
int
(
pygame
.
mixer
.
music
.
get_pos
()
/
1000
)
play_m
=
play_time
//
60
play_s
=
play_time
%
60
if
play_s
<
10
:
play_s
=
'0'
+
str
(
play_s
)
info
=
str
(
play_m
)
+
':'
+
str
(
play_s
)
#The songs' length
music_m
=
music_length
//
60
music_s
=
music_length
%
60
if
music_s
<
10
:
music_s
=
'0'
+
str
(
music_s
)
info2
=
str
(
music_m
)
+
':'
+
str
(
music_s
)
#
new_logo
=
pygame
.
transform
.
rotate
(
logo_img
,
angle
)
newRect
=
new_logo
.
get_rect
(
center
=
(
320
,
200
))
pos
=
(
newRect
[
0
],
newRect
[
1
])
...
...
@@ -103,6 +116,8 @@ while True:
screen
.
blit
(
next_img
,
(
420
,
350
))
# 下一曲
scoreSurf
=
b_f
.
render
(
info
,
True
,(
255
,
255
,
255
))
scoreSurf2
=
b_f
.
render
(
'/'
+
info2
,
True
,(
0
,
0
,
0
))
screen
.
blit
(
scoreSurf
,(
120
,
440
))
screen
.
blit
(
scoreSurf2
,(
170
,
440
))
# 刷新画面
pygame
.
display
.
update
()
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