Fix iOS playback: attach the Android-only audio effects only on Android

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
metatroncubeswdev 2026-10-31 17:50:41 -04:00
parent 60506e730f
commit 5c304ec494

View File

@ -4,6 +4,8 @@ import 'package:audio_service/audio_service.dart';
import 'package:audio_session/audio_session.dart';
import 'package:just_audio/just_audio.dart';
import 'sound_settings.dart';
/// Owns the [AudioPlayer] and exposes it to the OS (lock screen, notification,
/// headset and Bluetooth buttons) through audio_service.
class NkAudioHandler extends BaseAudioHandler with SeekHandler {
@ -15,8 +17,10 @@ class NkAudioHandler extends BaseAudioHandler with SeekHandler {
final equalizer = AndroidEqualizer();
final loudness = AndroidLoudnessEnhancer();
// just_audio activates every effect in the pipeline on load, whatever the platform, and the
// Android effects throw on iOS, so attach them only on Android.
late final _player = AudioPlayer(
audioPipeline: AudioPipeline(androidAudioEffects: [loudness, equalizer]),
audioPipeline: AudioPipeline(androidAudioEffects: soundEffectsSupported ? [loudness, equalizer] : const []),
);
Stream<Duration> get positionStream => _player.positionStream;