audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

Respect iOS Silient mode

Open ollyde opened this issue 2 years ago • 3 comments

How can we respect silent mode in iOS?

Using version 1.0.1

ollyde avatar Jul 05 '22 16:07 ollyde

Please take a look at the provided documentation about Audio Context: ref 1 ref 2

luanpotter avatar Jul 08 '22 04:07 luanpotter

@luanpotter I'm doing this but it doesn't work.

Also respectSilence: true not in the current version? (1.0.1)

final ctx = AudioContext(
  android: AudioContextAndroid(
    audioFocus: AndroidAudioFocus.none,
    contentType: AndroidContentType.unknown,
    isSpeakerphoneOn: false,
    stayAwake: false,
    usageType: AndroidUsageType.notification,
  ),
  iOS: AudioContextIOS(
    category: AVAudioSessionCategory.ambient,
    defaultToSpeaker: true,
    options: [
      AVAudioSessionOptions.allowAirPlay,
      AVAudioSessionOptions.allowBluetooth,
      AVAudioSessionOptions.mixWithOthers,
      AVAudioSessionOptions.allowBluetoothA2DP,
    ],
  ),
);

ollyde avatar Jul 08 '22 07:07 ollyde

Is this being looked into I can't seem to find respectSilence in v1.0.1

sezer-healthlogix avatar Aug 16 '22 01:08 sezer-healthlogix

You are sure this doesn't work, you have to make sure to set it globally:

final audioContext =  AudioContext(
  iOS: AudioContextIOS(
    category: AVAudioSessionCategory.ambient,
    options: [AVAudioSessionOptions.mixWithOthers],
  ),
)
AudioPlayer.global.setGlobalAudioContext(audioContext);

Gustl22 avatar Jan 21 '23 16:01 Gustl22