Skip to content

Commit

Permalink
fix(android): audio doesn't resume on interruption end
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Sep 27, 2023
1 parent 2eb3754 commit 15d466a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
5 changes: 0 additions & 5 deletions lib/provider/proxy_playlist/proxy_playlist_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 569,6 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier<ProxyPlaylist>
));

if (res.body == "Not Found") {
Catcher.reportCheckedError(
"[SponsorBlock] no skip segments found for $id\n"
"${res.request?.url}",
StackTrace.current,
);
return List.castFrom<dynamic, SkipSegment>([]);
}

Expand Down
32 changes: 24 additions & 8 deletions lib/services/audio_services/mobile_audio_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 18,32 @@ class MobileAudioService extends BaseAudioHandler {
session = s;
session?.configure(const AudioSessionConfiguration.music());
s.interruptionEventStream.listen((event) async {
switch (event.type) {
case AudioInterruptionType.duck:
await audioPlayer.setVolume(event.begin ? 0.5 : 1.0);
break;
case AudioInterruptionType.pause:
case AudioInterruptionType.unknown:
await audioPlayer.pause();
break;
if (event.begin) {
switch (event.type) {
case AudioInterruptionType.duck:
await audioPlayer.setVolume(0.5);
break;
case AudioInterruptionType.pause:
case AudioInterruptionType.unknown:
await audioPlayer.pause();
break;
}
} else {
switch (event.type) {
case AudioInterruptionType.duck:
await audioPlayer.setVolume(1.0);
break;
case AudioInterruptionType.pause:
case AudioInterruptionType.unknown:
await audioPlayer.resume();
break;
}
}
});

s.becomingNoisyEventStream.listen((_) {
audioPlayer.pause();
});
});
audioPlayer.playerStateStream.listen((state) async {
playbackState.add(await _transformEvent());
Expand Down

0 comments on commit 15d466a

Please sign in to comment.