3

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.

Ganapat
  • 6,984
  • 3
  • 24
  • 38
  • Could you add some code showcasing how you're playing sound ? The library is working well, we need more details to help you – FDuhen Aug 08 '22 at 06:33
  • @FDuhen I have added some code from the project. – Ganapat Aug 08 '22 at 08:48
  • can you try running the example app on your android setup? does that work? then try to replace the example file with your file? does that work? – Luan Nico Aug 08 '22 at 18:57

1 Answers1

0

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

Shirsh Shukla
  • 5,491
  • 3
  • 31
  • 44