Reputation: 7488
Flame Audio (flame_audio 1.2.0) is not playing the sound effects (wav or mp3) on an android device or emulator. But works fine on ios simulator.
I have tried playing "wav" & mp3 files but no error was shown either.
PFB my pubspect.yml
environment:
sdk: ">=2.17.6 <3.0.0"
dependencies:
flutter:
sdk: flutter
flame: 1.2.1
flame_audio: 1.2.0
cupertino_icons: 1.0.2
shared_preferences: 2.0.15
google_fonts: 3.0.1
logger: 1.1.0
Code I have to run play the audio :
//Inside onLoad(), loading all the files in cache
await FlameAudio.audioCache.loadAll(
['die.wav', 'hit.wav', 'point.wav', 'wing.wav', 'swooshing.wav']);
...
...
...
// In update method on certain events trying to play the sound
FlameAudio.play('hit.wav', volume: 1);
I have not made any changes in gradle files or AndroidManifest.xml, its as it is created by flutter on creating new project. My local flutter version is: 3.0.5
Am I missing something? Any help is appreciated.
Thank you.
Upvotes: 3
Views: 722
Reputation: 5973
I have tried this (mp3) example in the android emulator, but it works fine
void startBgmMusic() {
FlameAudio.bgm.initialize();
FlameAudio.bgm.play('music/bg_music.ogg');
}
void fireOne() {
FlameAudio.play('sfx/fire_1.mp3');
}
void fireTwo() {
pool.start();
}
can you try this example:- https://github.com/flame-engine/flame/tree/main/packages/flame_audio/example
Upvotes: 1