Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson5_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
3bdb04b4
authored
3 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
1754f9f4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
1 deletions
my_music.py
my_music.py
View file @
3bdb04b4
import
pygame
import
pygame
from
pygame
import
locals
from
pygame
import
locals
import
os
pygame
.
init
()
# 初始化
pygame
.
init
()
# 初始化
# 创建窗口
# 创建窗口
screen
=
pygame
.
display
.
set_mode
((
640
,
480
))
screen
=
pygame
.
display
.
set_mode
((
640
,
480
))
...
@@ -11,6 +11,41 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
...
@@ -11,6 +11,41 @@ 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'
)
# 下一曲按钮
w
=
[]
p
=
r'C:\Users\86139\Desktop\tzx'
e
=
os
.
listdir
(
p
)
for
i
in
e
:
if
i
[
-
4
:]
==
'.ogg'
or
i
[
-
4
:]
==
'.wav'
:
music_list
.
append
(
i
)
r
=-
1
t
=
0.2
pygame
.
mixer
.
set_t
(
t
)
y
=
0
u
=
stop_img
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
KEYDOWN
:
exit
()
if
event
.
key
==
locals
.
K_UP
:
t
+=
0.1
if
t
>
1
:
t
=
1
pygame
.
mixer
.
music
.
set_t
(
t
)
if
event
.
type
==
locals
.
K_DOWN
:
t
-=
0
,
1
if
t
<
0
:
t
=
1
pygame
.
mixer
.
music
.
set_t
(
t
)
if
event
.
type
==
locals
.
MOUSEBUTTONDOWN
:
chick
+=
1
if
chick
%
2
==
0
:
pygame
.
mixer
.
music
.
unpause
()
play_button
=
stop_img
else
:
pygame
.
mixer
.
music
.
pause
()
# 载入音乐
# 载入音乐
pygame
.
mixer
.
music
.
load
(
'歌曲4.ogg'
)
# 载入音乐
pygame
.
mixer
.
music
.
load
(
'歌曲4.ogg'
)
# 载入音乐
...
@@ -59,3 +94,34 @@ while True:
...
@@ -59,3 +94,34 @@ while True:
screen
.
blit
(
next_img
,
(
420
,
350
))
# 下一曲
screen
.
blit
(
next_img
,
(
420
,
350
))
# 下一曲
# 刷新画面
# 刷新画面
pygame
.
display
.
update
()
pygame
.
display
.
update
()
if
x
>
120
and
<
220
and
y
>
350
and
y
<
400
:
r
=
r
-
1
if
r
<
0
:
r
=
le
(
music_list
)
-
1
pygame
.
mixer
.
music
.
load
(
p
+
'
\\
'
+
music_list
(
r
))
pygame
.
mixer
.
music
.
play
()
click
=
0
play_button
=
stop_img
if
x
>
420
and
<
520
and
y
>
350
and
y
<
400
:
r
=
r
+
1
if
r
>
len
(
music_list
)
-
1
:
r
=
0
pygame
.
mixer
.
music
.
load
(
p
+
'
\\
'
+
music_list
(
r
))
pygame
.
mixer
.
music
.
play
()
click
=
0
play_button
=
stop_img
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
r
+=
1
if
r
>
len
(
filelist
):
nem
=
0
print
(
r
)
pygame
.
mixer
.
music
.
load
(
p
+
'
\\
'
+
music_list
(
r
))
pygame
.
mixer
.
music
.
play
()
\ 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