-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add extension method for App in bevy_audio that register custom Decodable types #6364
Copy link
Copy link
Closed
Labels
A-AudioSounds playback and modificationSounds playback and modificationC-FeatureA new feature, making something new possibleA new feature, making something new possible
Description
What problem does this solve or what need does it fill?
Related to #6362. Creating custom Decodable types requires boilerplate.
What solution would you like?
Create an extension trait for App.
trait AddAudioSource {
fn add_audio_source<Au>(&mut self) -> &mut Self
where
Au: Decodable + Asset;
}
impl AddAudioSource for App {
fn add_audio_source<Au>(&mut self) -> &mut Self
where
Au: Decodable + Asset
{
self.add_asset::<Au>
.init_resource::<Audio<Au>>()
.init_non_send_resource::<AudioOutput<Au>>()
.add_system_to_stage(CoreStage::PostUpdate, play_queued_audio_system::<Au>)
}
}What alternative(s) have you considered?
Simply do not do this. Manually register audio sources.
Additional context
See harudagondi/bevy_fundsp#6, especially in lib.rs and backend/bevy_audio.rs.
Also see bevy_oddio's implementation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-AudioSounds playback and modificationSounds playback and modificationC-FeatureA new feature, making something new possibleA new feature, making something new possible