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
9800045f
authored
Nov 04, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
ffdc3ca4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
my_music.py
my_music.py
View file @
9800045f
...
@@ -3,7 +3,8 @@ from pygame import locals
...
@@ -3,7 +3,8 @@ from pygame import locals
import
os
import
os
pygame
.
init
()
pygame
.
init
()
mt
=
pygame
.
mixer
.
Sound
(
few1
.
p
)
mn
=
pygame
.
mixer
.
Sound
(
fe
)
screen
=
pygame
.
display
.
set_mode
((
640
,
480
))
screen
=
pygame
.
display
.
set_mode
((
640
,
480
))
bg_img
=
pygame
.
image
.
load
(
'background.png'
)
# 背景图
bg_img
=
pygame
.
image
.
load
(
'background.png'
)
# 背景图
...
@@ -12,7 +13,8 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
...
@@ -12,7 +13,8 @@ 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'
)
# 下一曲按钮
mno
=
mn
.
get_lenght
()
mto
=
mt
.
get_lenght
()
music_list
=
[]
music_list
=
[]
path
=
"C:
\\
Users
\\
Administrator
\\
Desktop
\\
tast"
path
=
"C:
\\
Users
\\
Administrator
\\
Desktop
\\
tast"
filelist
=
os
.
listdir
(
path
)
filelist
=
os
.
listdir
(
path
)
...
@@ -76,17 +78,25 @@ while True:
...
@@ -76,17 +78,25 @@ while True:
click
+=
2
click
+=
2
else
:
else
:
click
+=
1
click
+=
1
mt
=
pygame
.
mixer
.
music
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
mto
=
mt
.
get_lenght
()
mto
=
int
(
mto
)
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
()
mt
=
pygame
.
mixer
.
music
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
mto
=
mt
.
get_lenght
()
mto
=
int
(
mto
)
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
play_s
=
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
)
info
=
str
(
play_m
)
+
':'
+
str
(
play_s
)
ScoreSurf
=
basic_font
.
render
(
info
,
True
,(
255
,
255
,
255
))
ScoreSurf
=
basic_font
.
render
(
info
,
True
,(
255
,
255
,
255
))
screen
.
blit
(
ScoreSurf
,(
120
,
440
))
screen
.
blit
(
ScoreSurf
,(
120
,
440
))
...
...
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