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 {
|
android {
|
||||||
compileSdkVersion 33
|
compileSdkVersion 34
|
||||||
|
|
||||||
ndkVersion "21.4.7075529"
|
ndkVersion "21.4.7075529"
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ class MobileAudioService extends BaseAudioHandler {
|
|||||||
AudioSession.instance.then((s) {
|
AudioSession.instance.then((s) {
|
||||||
session = s;
|
session = s;
|
||||||
session?.configure(const AudioSessionConfiguration.music());
|
session?.configure(const AudioSessionConfiguration.music());
|
||||||
|
|
||||||
|
bool wasPausedByBeginEvent = false;
|
||||||
|
|
||||||
s.interruptionEventStream.listen((event) async {
|
s.interruptionEventStream.listen((event) async {
|
||||||
if (event.begin) {
|
if (event.begin) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
@ -25,17 +28,23 @@ class MobileAudioService extends BaseAudioHandler {
|
|||||||
break;
|
break;
|
||||||
case AudioInterruptionType.pause:
|
case AudioInterruptionType.pause:
|
||||||
case AudioInterruptionType.unknown:
|
case AudioInterruptionType.unknown:
|
||||||
|
{
|
||||||
|
wasPausedByBeginEvent = audioPlayer.isPlaying;
|
||||||
await audioPlayer.pause();
|
await audioPlayer.pause();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case AudioInterruptionType.duck:
|
case AudioInterruptionType.duck:
|
||||||
await audioPlayer.setVolume(1.0);
|
await audioPlayer.setVolume(1.0);
|
||||||
break;
|
break;
|
||||||
case AudioInterruptionType.pause:
|
case AudioInterruptionType.pause when wasPausedByBeginEvent:
|
||||||
case AudioInterruptionType.unknown:
|
case AudioInterruptionType.unknown when wasPausedByBeginEvent:
|
||||||
await audioPlayer.resume();
|
await audioPlayer.resume();
|
||||||
|
wasPausedByBeginEvent = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user