Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes the sound is not restored. #174

Closed
synstin opened this issue Mar 28, 2024 · 14 comments
Closed

Sometimes the sound is not restored. #174

synstin opened this issue Mar 28, 2024 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@synstin
Copy link

synstin commented Mar 28, 2024

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 synstin added the bug Something isn't working label Mar 28, 2024
@gdelataillade
Copy link
Owner

Hi @synstin

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

@gdelataillade
Copy link
Owner

Hi @synstin

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

@pyjserv
Copy link

pyjserv commented Jun 26, 2024

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.

@pbouttier
Copy link

pbouttier commented Jul 12, 2024

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

@gdelataillade
Copy link
Owner

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 ?

@pbouttier
Copy link

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.

@pyjserv
Copy link

pyjserv commented Jul 14, 2024

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.

@gdelataillade
Copy link
Owner

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 ?

@pbouttier
Copy link

pbouttier commented Jul 15, 2024

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.

@pyjserv
Copy link

pyjserv commented Jul 15, 2024

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.

@gdelataillade
Copy link
Owner

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.

@pyjserv
Copy link

pyjserv commented Jul 15, 2024

Hi @gdelataillade

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

@gdelataillade
Copy link
Owner

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

@pbouttier
Copy link

Working fine, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants