-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
[Feature] Allow specifying the alarm volume using steps/stops #282
Conversation
Hi @orkun1675 Thanks for the PR ! Sure, I will test this on my devices. Are we doing the pigeon migration in this PR ? |
This PR is a clone of the previous one (when I moved my changes from PS: Today I started the Pigeon migration, Dart + Kotlin refactorings are complete, Swift is pending. |
31417a9
to
192e57e
Compare
d888d83
to
659ac1d
Compare
@gdelataillade this PR is now rebased to main and updated to utilize Pigeon and a more friendly public API. PTAL. |
@gdelataillade can we merge this so I can rebase and work on my follow-up PRs? We don't need to release a new version just yet if you'd like to work on the backwards compatibility aspect. |
@orkun1675 Yes, I intend to ensure backward compatibility before releasing version In the meantime, I can provide a development release, version |
Volume fade still broken in iOS (v5.0.0-dev.1)Hey, I just wanted to report that the iOS volume fade issue from #267 is still happening in 5.0.0-dev.1. I tried setting a 30-second fade, but the volume still jumps to max in like 2-3 seconds on device (iphone 16 pro). What I triedI tested with the latest dev version (5.0.0-dev.1) using both the regular fade and staircase fade: final VolumeSettings volumeSettings = VolumeSettings.fade(
volume: 1.0,
fadeDuration: Duration(seconds: 100),
); What's happeningWhen I run this, I see the log message: But in reality, the volume maxes out after just 2-3 seconds. I think I found the problemLooking at the code in ios/Classes/api/AlarmApiImpl.swift (L397-403): DispatchQueue.main.asyncAfter(deadline: now + startTime) {
if !audioPlayer.isPlaying {
return
}
print("[SwiftAlarmPlugin] Fading volume to \(targetVolume) over \(fadeDuration) seconds.")
audioPlayer.setVolume(targetVolume, fadeDuration: fadeDuration)
} I think there's a timing issue here.
Suggested fixWe probably need to convert the seconds to nanoseconds before adding them to the DispatchTime: let delayInNanoseconds = UInt64(startTime * Double(NSEC_PER_SEC))
DispatchQueue.main.asyncAfter(deadline: now + .nanoseconds(Int(delayInNanoseconds))) |
In that function the DispatchTime has nanosecond precision but I can't tell from the documentation what time unit the Double addition is assuming. You might be right about this, would you be interested in created a PR to fix this and test it? Simpler approach would be: DispatchQueue.main.asyncAfter(deadline: now + .seconds(startTime)) |
@onegigbyte a fix for your issue was published in |
(updated version of #276)
This PR allows alarm users to speicfy a staircase function to control the alarm volume.
It also fixes #267 by adding this line. For some reason AVAudioPlayer ignores volume changes unless the initial volume is set to zero.
PS: Overall, AVAudioPlayer has been a pain to deal with, setVolume has bugs, and it also doesn't report the real .volume value while a fade is in progress.
I've also taken the liberty to fix lint warnings in both iOS and Android native code.
I've tested using iOS and Android emulators + iOS physical device. I would appreciate if you could test this as well before merging. Thanks!