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
a2e52315
authored
Apr 11, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
6d6eb0a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
4 deletions
my_music.py
my_music.py
View file @
a2e52315
...
...
@@ -55,7 +55,8 @@ while True:
else
:
play_button
=
play_img
pygame
.
mixer
.
music
.
pause
()
if
x
>
420
and
x
<
520
and
y
>
350
and
y
<
400
:
# 下一曲
# 下一曲
if
x
>
420
and
x
<
520
and
y
>
350
and
y
<
400
:
num
+=
1
if
num
>
len
(
music_list
)
-
1
:
num
=
0
...
...
@@ -66,8 +67,12 @@ while True:
click
+=
2
else
:
click
+=
1
if
x
>
120
and
x
<
220
and
y
>
350
and
y
<
400
:
# 上一曲
#歌曲时间
music1
=
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
if
num
<
0
:
num
=
len
(
music_list
)
-
1
...
...
@@ -78,13 +83,22 @@ while True:
click
+=
2
else
:
click
+=
1
#歌曲时间
music1
=
pygame
.
mixer
.
Sound
(
path
+
'
\\
'
+
music_list
[
num
])
music_length
=
music1
.
get_length
()
music_length
=
int
(
music_length
)
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
#音乐是否正在播放
#音乐是否正在播放
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
num
+=
1
if
num
>
len
(
music_list
)
-
1
:
num
=
0
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
#歌曲时间
music1
=
pygame
.
mixer
.
Sound
(
path
+
'
\\
'
+
music_list
[
num
])
music_length
=
music1
.
get_length
()
music_length
=
int
(
music_length
)
#旋转后的唱盘图片
new_logo
=
pygame
.
transform
.
rotate
(
logo_img
,
angle
)
newRECT
=
new_logo
.
get_rect
(
center
=
(
320
,
200
))
...
...
@@ -96,8 +110,17 @@ while True:
play_time
=
int
(
play_time
/
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
)
text
=
my_font
.
render
(
info
,
True
,(
0
,
0
,
0
))
#渲染文字信息(内容,是否抗锯齿,RGB色号)
#歌曲的总时间长度
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
)
text2
=
my_font
.
render
(
'/'
+
info2
,
True
,(
255
,
255
,
255
))
# 绘制画面
screen
.
blit
(
bg_img
,
(
0
,
0
))
# 填充背景
screen
.
blit
(
play_button
,
(
270
,
330
))
# 暂停按钮
...
...
@@ -105,5 +128,6 @@ while True:
screen
.
blit
(
last_img
,
(
120
,
350
))
# 上一曲
screen
.
blit
(
next_img
,
(
420
,
350
))
# 下一曲
screen
.
blit
(
text
,(
120
,
410
))
#播放进度时间
screen
.
blit
(
text2
,(
180
,
410
))
#播放总时长
# 刷新画面
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