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
d8cc12c6
authored
Mar 24, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
64c22149
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
a.mp3
my_music.py
a.mp3
0 → 100644
View file @
d8cc12c6
File added
my_music.py
View file @
d8cc12c6
import
pygame
import
pygame
from
pygame
import
locals
from
pygame
import
locals
import
os
import
os
a
=
0
pygame
.
init
()
pygame
.
init
()
screen
=
pygame
.
display
.
set_mode
((
640
,
480
))
screen
=
pygame
.
display
.
set_mode
((
640
,
480
))
...
@@ -13,13 +13,16 @@ last_img = pygame.image.load('last.png') # 上一曲按钮
...
@@ -13,13 +13,16 @@ 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'
)
# 下一曲按钮
music_list
=
[]
music_list
=
[
"a.mp3"
]
path
=
"C:
\\
Users
\\
Administrator
\\
Desktop
\\
tast"
#path = "C:\\Users\\Administrator\\Desktop\\tast"
filelist
=
os
.
listdir
(
path
)
#filelist = os.listdir(path)
num
=
-
1
num
=
-
1
'''
for i in filelist:
for i in filelist:
if i[-4:] == ".wav" or i[-4:] == ".ogg":
if i[-4:] == ".wav" or i[-4:] == ".ogg":
music_list.append(i)
music_list.append(i)
'''
volume
=
0.2
volume
=
0.2
pygame
.
mixer
.
music
.
set_volume
(
volume
)
pygame
.
mixer
.
music
.
set_volume
(
volume
)
click
=
0
click
=
0
...
@@ -57,7 +60,7 @@ while True:
...
@@ -57,7 +60,7 @@ while True:
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
(
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
play
()
play_button
=
stop_img
play_button
=
stop_img
if
click
%
2
==
0
:
if
click
%
2
==
0
:
...
@@ -69,25 +72,28 @@ while True:
...
@@ -69,25 +72,28 @@ while True:
num
-=
1
num
-=
1
if
num
<
0
:
if
num
<
0
:
num
=
len
(
music_list
)
-
1
num
=
len
(
music_list
)
-
1
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
load
(
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
play
()
play_button
=
stop_img
play_button
=
stop_img
if
click
%
2
==
0
:
if
click
%
2
==
0
:
click
+=
2
click
+=
2
else
:
else
:
click
+=
1
click
+=
1
new_img
=
pygame
.
transform
.
rotate
(
logo_img
,
a
)
new_rect
=
new_img
.
get_rect
(
center
=
(
320
,
200
))
pos
=
(
new_rect
[
0
],
new_rect
[
1
])
a
+=
1
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
(
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
play
()
new_logo
=
pygame
.
transform
.
rotate
(
logo_img
,
angle
)
new_logo
=
pygame
.
transform
.
rotate
(
logo_img
,
angle
)
angle
+=
1
angle
+=
1
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
)
)
screen
.
blit
(
new_img
,
pos
)
screen
.
blit
(
last_img
,
(
120
,
350
))
screen
.
blit
(
last_img
,
(
120
,
350
))
screen
.
blit
(
next_img
,
(
420
,
350
))
screen
.
blit
(
next_img
,
(
420
,
350
))
...
...
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