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
bcc739de
authored
Apr 17, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
d1fc6085
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletions
my_music.py
my_music.py
View file @
bcc739de
...
@@ -2,6 +2,7 @@ import pygame
...
@@ -2,6 +2,7 @@ import pygame
from
pygame
import
locals
from
pygame
import
locals
import
os
import
os
angle
=
1
angle
=
1
music_length
=
0
pygame
.
init
()
# 初始化
pygame
.
init
()
# 初始化
# 创建窗口
# 创建窗口
screen
=
pygame
.
display
.
set_mode
((
640
,
480
))
screen
=
pygame
.
display
.
set_mode
((
640
,
480
))
...
@@ -69,6 +70,9 @@ while True:
...
@@ -69,6 +70,9 @@ while True:
else
:
else
:
click
+=
1
click
+=
1
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
:
# 上一曲
if
x
>
120
and
x
<
220
and
y
>
350
and
y
<
400
:
# 上一曲
num
-=
1
num
-=
1
if
num
<
0
:
if
num
<
0
:
...
@@ -81,19 +85,33 @@ while True:
...
@@ -81,19 +85,33 @@ while True:
else
:
else
:
click
+=
1
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
num
+=
1
if
num
>
len
(
music_list
)
-
1
:
if
num
>
len
(
music_list
)
-
1
:
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
])
music_length
=
music1
.
get_length
()
music_length
=
int
(
music_length
)
# 播放时间
# 播放时间
play_time
=
pygame
.
mixer
.
music
.
get_pos
()
play_time
=
pygame
.
mixer
.
music
.
get_pos
()
play_time
=
play_time
//
1000
play_time
=
play_time
//
1000
play_m
=
play_time
//
60
play_m
=
play_time
//
60
play_s
=
play_time
%
60
play_s
=
play_time
%
60
play_q
=
str
(
play_m
)
+
":"
+
str
(
play_s
)
play_q
=
str
(
play_m
)
+
":"
+
str
(
play_s
)
music_lengthm
=
music_length
//
60
music_lengths
=
music_length
%
60
music_lengthq
=
"/"
+
str
(
music_lengthm
)
+
":"
+
str
(
music_lengths
)
font_content
=
font
.
render
(
play_q
,
True
,(
250
,
250
,
250
))
font_content
=
font
.
render
(
play_q
,
True
,(
250
,
250
,
250
))
music_content
=
font
.
render
(
music_lengthq
,
True
,(
250
,
250
,
250
))
# 旋转图片play_q,
# 旋转图片play_q,
new_logo
=
pygame
.
transform
.
rotate
(
logo_img
,
angle
)
new_logo
=
pygame
.
transform
.
rotate
(
logo_img
,
angle
)
...
@@ -107,6 +125,7 @@ while True:
...
@@ -107,6 +125,7 @@ while True:
screen
.
blit
(
new_logo
,
pos
)
# 中间logo图
screen
.
blit
(
new_logo
,
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
(
font_content
,
(
200
,
200
))
screen
.
blit
(
font_content
,
(
120
,
440
))
screen
.
blit
(
music_content
,
(
170
,
440
))
# 刷新画面
# 刷新画面
pygame
.
display
.
update
()
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