Revert "fix(player): don't auto-resume after interruption while backgrounded"

This reverts commit 09714e3c64b22ccdc8a6555ffd6398b9cd205f23.
This commit is contained in:
zarzet
2026-07-14 09:10:18 +07:00
parent 5a1e898795
commit 4caf875da4
+3 -16
View File
@@ -5,7 +5,6 @@ import 'package:audio_service/audio_service.dart';
import 'package:audio_session/audio_session.dart'
show AudioSession, AudioSessionConfiguration, AudioInterruptionType;
import 'package:audioplayers/audioplayers.dart';
import 'package:flutter/widgets.dart';
import 'package:spotiflac_android/services/platform_bridge.dart';
import 'package:spotiflac_android/utils/logger.dart';
@@ -175,24 +174,12 @@ class MusicPlayerHandler extends BaseAudioHandler
}
// Focus returned; resume only if we paused due to a transient
// (duck/pause) interruption AND the app is foregrounded — a
// background play() has to startForegroundService(), which
// Android 12+ rejects (ForegroundServiceStartNotAllowedException)
// for programmatic starts. Keep _pausedByInterruption set in the
// background case so the media notification's play button (which
// IS exempt from the restriction) still resumes normally.
// (duck/pause) interruption.
_interruptionActive = false;
if (_pausedByInterruption &&
event.type == AudioInterruptionType.pause) {
if (WidgetsBinding.instance.lifecycleState ==
AppLifecycleState.resumed) {
_pausedByInterruption = false;
unawaited(play());
} else {
_log.i(
'Skipping auto-resume after interruption: app is backgrounded',
);
}
_pausedByInterruption = false;
unawaited(play());
} else {
_pausedByInterruption = false;
}