alarm icon indicating copy to clipboard operation
alarm copied to clipboard

Sometimes the sound is not restored.

Open synstin opened this issue 10 months ago • 1 comments

Alarm plugin version 3.0.14

Describe the bug When the alarm goes off, the music I have set as background music gets smaller and then doesn't come back.

For example, if I listen to it at volume 3 and when the break alarm goes off, it goes down to about 1 and then comes right back up, but sometimes it goes down to about 1 and then doesn't come back, even if I quit the app after that, it stays at 1 and I have to turn off the music app completely and turn it back on to get it back to the original volume.

Device info SM-N960N - Android 10 (SDK 29)

synstin avatar Mar 28 '24 02:03 synstin

Hi @synstin

OK I'll try to fix it in the next release.

gdelataillade avatar Mar 28 '24 12:03 gdelataillade

Hi @synstin

Do you still experience this kind of issue in the latest releases ?

gdelataillade avatar Jun 10 '24 14:06 gdelataillade

Do you still experience this kind of issue in the latest releases ?

Hi @gdelataillade

I am experiencing the same issue. When I listen to YouTube live music, after the alarm music ends, the volume of the YouTube live music does not return to its original level. I have to close my app or reopen YouTube to restore it to normal. Additionally, if I use MX Player Pro or Solid Explorer to play music, the volume of the music playing does not decrease when the alarm goes off. My alarm version is 3.1.4, and the device is SM-A326BR/DS, Android 13.

Update: I tested older versions and found that versions 3.0.11 and earlier work fine, while starting from version 3.0.12, the volume of YouTube does not return to its original level.

pyjserv avatar Jun 26 '24 14:06 pyjserv

Same things here, on 3.0.12 // 3.1.4 the sound is reduced until the app his killed, on Android. It's working in 3.0.11.

Thanks in advance

pbouttier avatar Jul 12 '24 13:07 pbouttier

Hi @pyjserv and @pbouttier

I'm looking at the differences between versions 3.0.11 and 3.0.12 but I don't see nothing related to the system volume... Do you have the issue all the time ? Or with what frequency ?

gdelataillade avatar Jul 14 '24 13:07 gdelataillade

I tested it 2-3 times on each version, and it happened every time.

In 3.0.11 it seems to me that the app triggers a warning, java version 8 is used, maybe that's where it comes from? My test phone is running Android 11, so I haven't tested it with an emulator or any other version.

pbouttier avatar Jul 14 '24 13:07 pbouttier

Hi @gdelataillade

I tested my two Samsung devices with Android 13 and Android 11, and the issue persists in versions 3.0.12 and above. However, it works fine in versions 3.0.11 and below.

pyjserv avatar Jul 14 '24 23:07 pyjserv

In your tests, do you guys set the loopAudio to false ? Or do you stop the alarm manually ? This way I could know better what piece of code is wrong.

@pbouttier Could you share the warning triggered by the app in 3.0.11 ?

gdelataillade avatar Jul 15 '24 08:07 gdelataillade

warning seen only with --profile, not on debug, not on release

warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings

I had the same problem on the core of my app, I switched to java 11 in build.gradle, like this

android {
   ....

    def javaVersion = 11;
    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility = javaVersion // The minimum value
        targetCompatibility = javaVersion // The minimum value
    }

  ...
}

my settings are

  Future<void> setAlarm(DateTime dateTime) async {
    UserSettingsModel userSettings = await ref.read(userSettingsProvider.future);

    final alarmSettings = AlarmSettings(
      id: alarmId,
      dateTime: dateTime,
      assetAudioPath: 'assets/audio/alarm.mp3',
      loopAudio: false,
      vibrate: userSettings.noticeEndCountdown == NoticeEndCountdown.vibrate,
      // Le son est indépendant du son configuré à l'instant T sur Android, ça le remet brieffement à cette valeur
      volume: userSettings.noticeEndCountdown == NoticeEndCountdown.sound ? userSettings.countdownVolume : 0.0, 
      notificationTitle: tr('workout.ongoing.notification_countdown.title'),
      notificationBody: tr('workout.ongoing.notification_countdown.body'),
    );
    await Alarm.set(alarmSettings: alarmSettings);
  }

I tested with a fixed value for the sound, instead of my user settings, and it made no difference.

the audio is a 1s double bip.

pbouttier avatar Jul 15 '24 09:07 pbouttier

Hi @gdelataillade

In your tests, do you guys set the loopAudio to false ?

I set loopAudio to true.

Or do you stop the alarm manually ?

Yes, I use Alarm.stop(id) to stop alarm.

I think I found the part causing the issue. In AlarmPlugin.kt, fun onMethodCall(), label "stopAlarm",

line 58 in version 3.0.12

change context.stopService(stopIntent) to context.startService(stopIntent)

This restores the volume to normal after calling Alarm.stop(id).

Update: Perhaps this issue is due to the service not being completely stopped.

pyjserv avatar Jul 15 '24 09:07 pyjserv

Hi guys,

I think I found a quick fix, at least it worked for my Android 11 device. I just released a new version (3.1.5), please tell me if it works for you.

What I did was just to make sure that the audio focus was abandoned when the AlarmService was destroyed.

gdelataillade avatar Jul 15 '24 14:07 gdelataillade

Hi @gdelataillade

I have tested version 3.1.5, and it worked perfectly! Thank you very much for the fix!

pyjserv avatar Jul 15 '24 14:07 pyjserv

Nice ! I'm glad it works now and thank you so much for your help.

gdelataillade avatar Jul 15 '24 15:07 gdelataillade

Working fine, thanks :)

pbouttier avatar Jul 16 '24 06:07 pbouttier