[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 02/07: Adjust volume for payment sounds
From: |
gnunet |
Subject: |
[taler-taler-ios] 02/07: Adjust volume for payment sounds |
Date: |
Thu, 26 Oct 2023 13:21:28 +0200 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit 8767f5abddd2f4eb7e8635c2907d71f1b1abc87f
Author: Marc Stibane <marc@taler.net>
AuthorDate: Thu Oct 26 01:00:13 2023 +0200
Adjust volume for payment sounds
---
TalerWallet1/Helper/Controller+playSound.swift | 33 ++++++++++++++++++++++----
1 file changed, 28 insertions(+), 5 deletions(-)
diff --git a/TalerWallet1/Helper/Controller+playSound.swift
b/TalerWallet1/Helper/Controller+playSound.swift
index bf6a784..7e76e36 100644
--- a/TalerWallet1/Helper/Controller+playSound.swift
+++ b/TalerWallet1/Helper/Controller+playSound.swift
@@ -10,13 +10,34 @@ extension Controller {
/// 0 = failure, 1 = received, 2 = sent
@MainActor func playSound(_ number: Int) {
+ let sysVolume = AVAudioSession.sharedInstance().outputVolume
+ let volume = sysVolume < 0.16 ? 2.5 // too bad we cannot make it
louder
+ : sysVolume < 0.21 ? 1.5 // nope, doesn't work
+ : sysVolume < 0.26 ? 1.0 // this is full volume...
+ : sysVolume < 0.31 ? 0.9 // and
+// : sysVolume < 0.36 ?
+ : sysVolume < 0.41 ? 0.8 // we
+// : sysVolume < 0.46 ?
+ : sysVolume < 0.51 ? 0.7 // must
+ : sysVolume < 0.56 ? 0.6 // reduce
+// : sysVolume < 0.61 ?
+ : sysVolume < 0.66 ? 0.5 // it,
+ : sysVolume < 0.71 ? 0.4 // or
+ : sysVolume < 0.76 ? 0.3 // it'll
+ : sysVolume < 0.81 ? 0.2 // play
+ : sysVolume < 0.86 ? 0.15 // way
+ : sysVolume < 0.91 ? 0.10 // too
+ : 0.07 // loud!
+// logger.log("❗️sys:\(sysVolume) vol:\(volume)")
+
var soundID: SystemSoundID = 0
let notificationGenerator = useHaptics ?
UINotificationFeedbackGenerator() : nil
if number > 9 {
soundID = UInt32(number)
} else {
let sound = (number == 0) ? "payment_failure" :
- (number == 1) ? "payment_success" : "PaymentReceived"
+ (number == 1) ? "payment_success"
+ : "PaymentReceived"
let fileURL = URL(fileURLWithPath:
"/System/Library/Audio/UISounds/"
+ sound + ".caf")
AudioServicesCreateSystemSoundID(fileURL as CFURL, &soundID)
@@ -25,13 +46,14 @@ extension Controller {
if number == 0 || number > 9 || playSounds < 0 {
AudioServicesPlaySystemSound(soundID);
} else if playSounds > 0 {
- if let url = Bundle.main.url(forResource: (number == 1) ?
"payment_received"
- :
"payment_sent",
- withExtension: "m4a") {
+ if let url = Bundle.main.url(forResource: (number == 1) ?
"payment_sent"
+ :
"payment_received",
+ withExtension: "m4a") {
player.removeAllItems()
player.insert(AVPlayerItem(url: url), after: nil)
- logger.log("\(url, privacy: .public) \(soundID)")
+ logger.log("\(url, privacy: .public)")
player.play()
+ player.volume = Float(volume)
} else {
AudioServicesPlaySystemSound(soundID);
}
@@ -39,5 +61,6 @@ extension Controller {
if let notificationGenerator {
notificationGenerator.notificationOccurred(number == 0 ? .error :
.success)
}
+
}
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] branch master updated (686fcd4 -> 9f7de5c), gnunet, 2023/10/26
- [taler-taler-ios] 02/07: Adjust volume for payment sounds,
gnunet <=
- [taler-taler-ios] 05/07: Currency Symbol, gnunet, 2023/10/26
- [taler-taler-ios] 07/07: Bump version to 0.9.3 (22), gnunet, 2023/10/26
- [taler-taler-ios] 03/07: Accessibility: QR, Date, gnunet, 2023/10/26
- [taler-taler-ios] 01/07: Different Icon for Taler Wallet, gnunet, 2023/10/26
- [taler-taler-ios] 04/07: Abbreviations, gnunet, 2023/10/26
- [taler-taler-ios] 06/07: Fixed Balances layout for dynamic font sizes (Previews work again), gnunet, 2023/10/26