Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dos
flow3r firmware
Commits
12320f0e
Verified
Commit
12320f0e
authored
1 year ago
by
dos
Browse files
Options
Downloads
Patches
Plain Diff
sim: fakes: Implement a fake for media module using pygame mixer
parent
a273eb55
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sim/fakes/media.py
+77
-3
77 additions, 3 deletions
sim/fakes/media.py
with
77 additions
and
3 deletions
sim/fakes/media.py
+
77
−
3
View file @
12320f0e
import
pygame
from
_sim
import
path_replace
_loaded
=
False
def
stop
():
"""
Stops media playback, frees resources.
"""
pass
global
_loaded
_loaded
=
False
pygame
.
mixer
.
music
.
stop
()
pygame
.
mixer
.
music
.
unload
()
def
load
(
path
):
def
load
(
path
,
paused
=
False
):
"""
Load path
"""
pass
global
_loaded
if
path
.
startswith
((
"
http://
"
,
"
https://
"
)):
return
pygame
.
mixer
.
music
.
load
(
path_replace
(
path
))
pygame
.
mixer
.
music
.
play
()
if
paused
:
pygame
.
mixer
.
music
.
pause
()
_loaded
=
True
def
play
():
if
not
_loaded
:
return
pygame
.
mixer
.
music
.
unpause
()
def
pause
():
if
not
_loaded
:
return
pygame
.
mixer
.
music
.
pause
()
def
is_playing
():
if
not
_loaded
:
return
False
return
pygame
.
mixer
.
music
.
get_busy
()
def
draw
(
ctx
):
...
...
@@ -24,3 +58,43 @@ def think(delta_ms):
Process ms amounts of media, queuing PCM data and preparing for draw()
"""
pass
def
set_volume
(
vol
):
if
not
_loaded
:
return
pygame
.
mixer
.
music
.
set_volume
(
vol
)
def
get_volume
():
if
not
_loaded
:
return
1.0
return
pygame
.
mixer
.
music
.
get_volume
()
def
get_position
():
if
not
_loaded
:
return
0
pos
=
pygame
.
mixer
.
music
.
get_pos
()
/
1000
if
pos
<
0
:
pos
=
get_duration
()
return
pos
def
get_time
():
return
get_position
()
def
seek
(
pos
):
if
not
_loaded
:
return
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
rewind
()
def
get_duration
():
return
99999
def
is_visual
():
return
False
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment