Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson6_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
696e9371
authored
3 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
df13c5fb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
my_music.py
my_music.py
View file @
696e9371
...
@@ -12,7 +12,7 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
...
@@ -12,7 +12,7 @@ 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'
)
# 下一曲按钮
basic_font
=
pygame
.
font
.
Font
(
"neuropol.ttf"
,
21
)
music_list
=
[]
music_list
=
[]
path
=
"C:
\\
Users
\\
admin
\\
Desktop
\\
text"
path
=
"C:
\\
Users
\\
admin
\\
Desktop
\\
text"
filelist
=
os
.
listdir
(
path
)
filelist
=
os
.
listdir
(
path
)
...
@@ -59,6 +59,8 @@ while True:
...
@@ -59,6 +59,8 @@ while True:
num
=
0
num
=
0
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
play
()
music1
=
pygame
.
mixer
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
music1_length
=
int
(
music1
.
get_length
())
play_button
=
stop_img
play_button
=
stop_img
if
click
%
2
==
0
:
if
click
%
2
==
0
:
click
+=
2
click
+=
2
...
@@ -71,6 +73,8 @@ while True:
...
@@ -71,6 +73,8 @@ while True:
num
=
len
(
music_list
)
-
1
num
=
len
(
music_list
)
-
1
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
play
()
music1
=
pygame
.
mixer
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
music1_length
=
int
(
music1
.
get_length
())
play_button
=
stop_img
play_button
=
stop_img
if
click
%
2
==
0
:
if
click
%
2
==
0
:
click
+=
2
click
+=
2
...
@@ -83,6 +87,8 @@ while True:
...
@@ -83,6 +87,8 @@ while True:
num
=
0
num
=
0
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
play
()
music1
=
pygame
.
mixer
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
music1_length
=
int
(
music1
.
get_length
())
play_time
=
pygame
.
mixer
.
music
.
get_pos
()
play_time
=
pygame
.
mixer
.
music
.
get_pos
()
play_time
=
int
(
play_time
/
1000
)
play_time
=
int
(
play_time
/
1000
)
play_m
=
play_time
//
60
play_m
=
play_time
//
60
...
@@ -91,11 +97,24 @@ while True:
...
@@ -91,11 +97,24 @@ while True:
play_s
=
"0"
+
str
(
play_s
)
play_s
=
"0"
+
str
(
play_s
)
info
=
str
(
play_m
)
+
":"
+
str
(
play_s
)
info
=
str
(
play_m
)
+
":"
+
str
(
play_s
)
print
(
info
)
print
(
info
)
music1
=
pygame
.
mixer
.
music
.
get_pos
()
music1
=
int
(
play_time
/
1000
)
music1_m
=
play_time
//
60
music1_s
=
play_time
%
60
if
music1_s
<
10
:
music1_s
=
"0"
+
str
(
play_s
)
info1
=
str
(
music1_m
)
+
":"
+
str
(
music1_s
)
print
(
info1
)
# 绘制画面
# 绘制画面
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_img
,
(
170
,
60
))
# 中间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
))
# 下一曲
scoreSurt
=
basic_font
.
render
(
info
,
Ture
,(
255
,
255
,
255
))
screen
.
blit
(
scoreSurt
,(
120
,
440
))
scoreSurt2
=
basic_font
.
render
(
"/"
+
info2
,
Ture
,(
0
,
0
,
0
))
sceen
.
blit
(
scoreSurt2
,(
170
,
440
)
# 刷新画面
# 刷新画面
pygame
.
display
.
update
()
pygame
.
display
.
update
()
\ No newline at end of file
\ No newline at end of file
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