NiklasEi / bevy_kira_audio

A Bevy plugin to use Kira for game audio
Apache License 2.0
348 stars 54 forks source link

Give warning when trying to play sound in a format for which the feature is not enabled #15

Closed bjorn3 closed 3 years ago

bjorn3 commented 3 years ago

Sound didn't work for someone on the bevy discord: https://discord.com/channels/691052431525675048/742884593551802431/857300358158352465 It turns out that the "wav" feature was not enabled. No warnings whatsoever were shown. It wasn't until I looked at the Cargo.toml that I found the problem.

NiklasEi commented 3 years ago

Isn't that something that should happen in Bevy itself? The asset server is responsible to load the wav file. If the wav feature is not enabled there will be no loader registered for the audio file.

As far as I remember I used to get logs from Bevy when I tried to load an asset that had no registered loader, but I just tested it with the audio example and could not reproduce. A very quick look into engine code suggests though that a "missing loader" error should be logged. Maybe I am doing something wrong with my loaders here, or it is a Bevy issue?

Thank you for helping out on Discord!

bjorn3 commented 3 years ago

Could it be that the asset loader for bevy_audio gets used instead of bevy_kira_audio when the feature flag is disabled?

NiklasEi commented 3 years ago

To use bevy_kira_audio the Bevy audio feature should not be selected. That's actually a very good point, I don't think I mentioned that explicitly in the readme.

The wav file should not be loaded by bevy though in this case. All bevy_audio asset loaders apart from the mp3 loader are not enabled by default.

NiklasEi commented 3 years ago

I'll close this for now as I don't think there is anything more I can do here. When a user tries to load an asset that the engine doesn't know a loader for, Bevy logs a warning.

That users of this crate should disable Bevy's audio feature is now documented.