Referenced audio in Flutter broken for non-WAV files
When attempting to play referenced audio from a Rive file, the Flutter Rive runtime (checked using 0.13.20
) will always attempt to load audio as a .WAV -- regardless of the export type from Rive.
In Rive: create an audio clip with an MP3 or FLAC file and set it to referenced/source (or force the format to MP3 or FLAC). Play this sound in some timeline
In Flutter: Load the Rive animation and use the FileAssetLoader
class to point to the directory you exported the MP3/FLAC files.
At runtime, you'll see that the Rive runtime is piping in .wav
as the extension regardless of what the source file is. This causes the file to fail to load. You can even create your own asset loader to fix the filename issue, but then the audio still does not play (presumedly because the Rive runtime is still expecting WAV data, not the compressed MP3/FLAC data that actually exists)
Minimum Flutter Repro Project (with .rev source file in assets/rive)
Example error of incorrect file loading for referenced audio:
Rive file initialized Error while trying to load an asset: Flutter Web engine failed to fetch "assets/rive/ref_force_mp3-1342456.wav". HTTP request succeeded, but the server responded with HTTP status 404. DartError: Unable to load asset: "rive/ref_force_mp3-1342456.wav". The asset does not exist or has empty data.