Moving PlaybackMode
to AudioPlayer
and defaulting to PlaybackMode::Remove
#16598
+55
−63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Fix: #12359
Wanted to make it clear what happens when audio is being played, and the source is related to the
PlaybackMode
.You're either playing sound effects that are temporary in lifetime, or constant repeated music.
Some sound effects related to existing entity while others are children of said entities.
I wanted the API to actually reflect that, instead of being split over two components.
It requires explicit input about
PlaybackMode
This break existing code in two places:
AudioPlayer::new()
is used it changes default mode toRemove
, current default isOnce
.Solution
PlaybackMode
toPlaybackMode::Remove
PlaybackMode
toAudioPlayer
AudioPlayer
to create with differentPlaybackMode
sTesting
Performance? Since
AudioPlayer
now holdsPlaybackMode
there can have been a difference in internal optimizations that I might have missed.Run audio examples.
Tested only on
macOS
, I don't think it's relevant for other platforms unless there are performance implications with the new defaultremove
forPlaybackMode
.Migration Guide
Changed the default behaviour to be
remove
Introducing new functions to create
AudioPlayer
Examples:
Old
New
Old
New