mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
fix: audio resumes after a phone call even if it was paused before #926
This commit is contained in:
parent
9bd16e096f
commit
fd1899f162
@ -32,7 +32,7 @@ if (keystorePropertiesFile.exists()) {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 33
|
||||
compileSdkVersion 34
|
||||
|
||||
ndkVersion "21.4.7075529"
|
||||
|
||||
|
@ -17,6 +17,9 @@ class MobileAudioService extends BaseAudioHandler {
|
||||
AudioSession.instance.then((s) {
|
||||
session = s;
|
||||
session?.configure(const AudioSessionConfiguration.music());
|
||||
|
||||
bool wasPausedByBeginEvent = false;
|
||||
|
||||
s.interruptionEventStream.listen((event) async {
|
||||
if (event.begin) {
|
||||
switch (event.type) {
|
||||
@ -25,17 +28,23 @@ class MobileAudioService extends BaseAudioHandler {
|
||||
break;
|
||||
case AudioInterruptionType.pause:
|
||||
case AudioInterruptionType.unknown:
|
||||
{
|
||||
wasPausedByBeginEvent = audioPlayer.isPlaying;
|
||||
await audioPlayer.pause();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (event.type) {
|
||||
case AudioInterruptionType.duck:
|
||||
await audioPlayer.setVolume(1.0);
|
||||
break;
|
||||
case AudioInterruptionType.pause:
|
||||
case AudioInterruptionType.unknown:
|
||||
case AudioInterruptionType.pause when wasPausedByBeginEvent:
|
||||
case AudioInterruptionType.unknown when wasPausedByBeginEvent:
|
||||
await audioPlayer.resume();
|
||||
wasPausedByBeginEvent = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user