Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Bevy Music Box
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Music Box
Commits
7a2e9a08
Verified
Commit
7a2e9a08
authored
2 years ago
by
Louis
Browse files
Options
Downloads
Patches
Plain Diff
Add convenience methods for working directly with handles
parent
ae2eb221
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/music_box.rs
+37
-0
37 additions, 0 deletions
src/music_box.rs
with
37 additions
and
0 deletions
src/music_box.rs
+
37
−
0
View file @
7a2e9a08
...
@@ -352,6 +352,43 @@ impl<'w, 's, T: SuppliesAudio> MusicBox<'w, 's, T> {
...
@@ -352,6 +352,43 @@ impl<'w, 's, T: SuppliesAudio> MusicBox<'w, 's, T> {
self
.settings.ui_volume
=
level
;
self
.settings.ui_volume
=
level
;
}
}
/// Stop an audio instance handle from playing immediately
pub
fn
stop_handle
(
&
mut
self
,
handle
:
&
Handle
<
AudioInstance
>
)
{
if
let
Some
(
instance
)
=
self
.audio_instances
.get_mut
(
handle
)
{
instance
.stop
(
AudioTween
::
default
());
}
}
/// Stop an audio instance handle from playing with a given tween
pub
fn
stop_handle_with_tween
(
&
mut
self
,
handle
:
&
Handle
<
AudioInstance
>
,
tween
:
AudioTween
)
{
if
let
Some
(
instance
)
=
self
.audio_instances
.get_mut
(
handle
)
{
instance
.stop
(
tween
);
}
}
/// Pause an audio instance handle immediately, in a way that can be resumed later
pub
fn
pause_handle
(
&
mut
self
,
handle
:
&
Handle
<
AudioInstance
>
)
{
if
let
Some
(
instance
)
=
self
.audio_instances
.get_mut
(
handle
)
{
instance
.pause
(
AudioTween
::
default
());
}
}
/// Pause an audio instance with a given tween in a way that can be resumed later
pub
fn
pause_handle_with_tween
(
&
mut
self
,
handle
:
&
Handle
<
AudioInstance
>
,
tween
:
AudioTween
)
{
if
let
Some
(
instance
)
=
self
.audio_instances
.get_mut
(
handle
)
{
instance
.pause
(
tween
);
}
}
/// Stop an audio instance handle from playing immediately
pub
fn
resume_handle
(
&
mut
self
,
handle
:
&
Handle
<
AudioInstance
>
)
{
if
let
Some
(
instance
)
=
self
.audio_instances
.get_mut
(
handle
)
{
instance
.resume
(
AudioTween
::
default
());
}
}
/// Stop an audio instance handle from playing with a given tween
pub
fn
resume_handle_with_tween
(
&
mut
self
,
handle
:
&
Handle
<
AudioInstance
>
,
tween
:
AudioTween
)
{
if
let
Some
(
instance
)
=
self
.audio_instances
.get_mut
(
handle
)
{
instance
.resume
(
tween
);
}
}
fn
map_tracks
<
Name
:
ToString
>
(
&
'w
self
,
name
:
Name
)
->
TrackType
<
Handle
<
AudioSource
>>
{
fn
map_tracks
<
Name
:
ToString
>
(
&
'w
self
,
name
:
Name
)
->
TrackType
<
Handle
<
AudioSource
>>
{
match
self
.handles
.resolve_track_name
(
name
)
{
match
self
.handles
.resolve_track_name
(
name
)
{
TrackType
::
Single
(
name
)
=>
match
self
.handles
.get_audio_track
(
name
)
{
TrackType
::
Single
(
name
)
=>
match
self
.handles
.get_audio_track
(
name
)
{
...
...
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