Skip to content

Commit

Permalink
fix: handle audio interrupt correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Yesterday17 committed Sep 21, 2024
1 parent de115ec commit 33cba7e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/services/audio_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class AnnixAudioHandler extends BaseAudioHandler {
// unplugged
session.becomingNoisyEventStream.listen((final _) => service.pause());

bool pausedByInterrupt = false;
// interruption
session.interruptionEventStream.listen((final event) {
if (event.begin) {
Expand All @@ -68,7 +67,6 @@ class AnnixAudioHandler extends BaseAudioHandler {
break;
case AudioInterruptionType.pause:
case AudioInterruptionType.unknown:
pausedByInterrupt = true;
service.pause();
break;
}
Expand All @@ -79,11 +77,9 @@ class AnnixAudioHandler extends BaseAudioHandler {
// TODO
break;
case AudioInterruptionType.pause:
service.play();
// We should not resume unknown interruptions
case AudioInterruptionType.unknown:
if (pausedByInterrupt) {
pausedByInterrupt = false;
service.play();
}
break;
}
}
Expand Down

0 comments on commit 33cba7e

Please sign in to comment.