Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson6_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
5911fe8a
authored
Mar 06, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
5aa2f170
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
2 deletions
my_music.py
my_music.py
View file @
5911fe8a
...
...
@@ -13,7 +13,7 @@ last_img = pygame.image.load('last.png') # 上一曲按钮
next_img
=
pygame
.
image
.
load
(
'next.png'
)
# 下一曲按钮
logo_img
=
pygame
.
image
.
load
(
'logo.png'
)
# 下一曲按钮
basic_font
=
pygame
.
font
.
Font
(
'neuropol.ttf'
,
14
)
angle
=
0
music_list
=
[]
path
=
"c:
\\
Users
\\
admin
\
Desktop
\\
text"
filelist
=
os
.
listdir
(
path
)
...
...
@@ -25,7 +25,7 @@ volume = 0.2
pygame
.
mixer
.
music
.
set_volume
(
volume
)
# 初始播放音量
click
=
0
play_button
=
stop_img
angle
=
0
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
...
...
@@ -60,11 +60,17 @@ while True:
num
=
0
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
music
=
pygame
.
mixer
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
music_length
=
music1
.
get_length
()
music_length
=
int
(
music_length
)
play_button
=
stop_img
if
click
%
2
==
0
:
click
+=
2
else
:
click
+=
1
music
=
pygame
.
mixer
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
music_length
=
music1
.
get_length
()
music_length
=
int
(
music_length
)
if
x
>
120
and
x
<
220
and
y
>
350
and
y
<
400
:
# 上一曲
num
-=
1
...
...
@@ -72,6 +78,9 @@ while True:
num
=
len
(
music_list
)
-
1
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
music
=
pygame
.
mixer
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
music_length
=
music1
.
get_length
()
music_length
=
int
(
music_length
)
play_button
=
stop_img
if
click
%
2
==
0
:
click
+=
2
...
...
@@ -84,12 +93,24 @@ while True:
num
=
0
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
music1
=
pygame
.
mixer
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
music1_length
=
music1
.
get_length
()
music1_length
=
int
(
music1_length
)
play_time
=
pygame
.
mixer
.
music
.
get_pos
()
play_time
=
int
(
play_time
/
1000
)
play_m
=
play_time
//
60
play_s
=
play_time
%
60
info
=
str
(
play_m
)
+
":"
+
str
(
play_s
)
music_m
=
music_length
//
60
music
=
music_length
%
60
if
music_s
<
10
:
music_s
=
"0"
+
str
(
music_s
)
infi
=
str
(
music_m
)
+
":"
+
str
(
music_s
)
new_logo
=
pygame
.
transform
.
rotate
(
logo_img
,
angle
)
newrcet
=
new_logo
.
get_rect
(
center
=
(
320
,
200
))
...
...
@@ -105,4 +126,6 @@ while True:
# 刷新画面
scoresurf
=
basic_font
.
render
(
info
,
True
,(
255
,
255
,
255
))
screen
.
blit
(
scoresurf
,(
120
,
440
))
scoresurf2
=
basic_font
.
render
(
"/"
+
info2
,
True
,(
0
,
0
,
0
))
screen
.
blit
(
scoresurf
,(
170
,
440
))
pygame
.
display
.
update
()
\ 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