bluefireteam / audioplayers

A Flutter package to play multiple audio files simultaneously (Android/iOS/web/Linux/Windows/macOS)
https://pub.dartlang.org/packages/audioplayers
MIT License
2.01k stars 845 forks source link

All I/O should be stopped or paused prior to deactivating the audio session. #960

Open tamoyal opened 3 years ago

tamoyal commented 3 years ago

I receive an error from AVAudioSession (iOS) when using the AudioCache class in a fairly simple scenario.

Full Description When playing a file using the AudioCache, I consistently see this error in my logs:

[avas]     AVAudioSession_iOS.mm:1206  Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session.
[plugin] Error deactivation: The operation couldn’t be completed. (OSStatus error 560030580.)

Code to Reproduce My audio class looks like this.

import 'package:audioplayers/src/audio_cache.dart';
import 'package:audioplayers/audioplayers.dart';

class ChatSounds {
  static final cache =
      AudioCache(fixedPlayer: AudioPlayer(mode: PlayerMode.LOW_LATENCY));

  Future<void> playCorrect() async {
    await cache.play('sounds/correct.mp3', volume: 0.5);
  }
}

Then I just call playCorrect in a widget. Nothing crazy but happy to create a new Flutter project with this if it helps.

This is the file (zipped because github doesn't accept mp3s): correct.mp3.zip

Platform stuffz: iOS 4.6 iPhone Xs Flutter 2.2.3 (stable) audioplayers version 0.19.1

Ucoon commented 2 years ago

any solutions?