(volume: Percentage)
| 14 | * @param volume - The volume level to play the sound at, as a percentage (`0`–`100`). |
| 15 | */ |
| 16 | export async function raiseSoundNotification(volume: Percentage) { |
| 17 | if (!cachedAudio) { |
| 18 | const path = await window.gitify.notificationSoundPath(); |
| 19 | |
| 20 | cachedAudio = new Audio(path); |
| 21 | } |
| 22 | |
| 23 | const audio = cachedAudio; |
| 24 | |
| 25 | audio.volume = volumePercentageToLevel(volume); |
| 26 | |
| 27 | try { |
| 28 | await audio.play(); |
| 29 | } catch (err) { |
| 30 | rendererLogError( |
| 31 | 'audio', |
| 32 | 'Failed to play notification sound:', |
| 33 | toError(err), |
| 34 | ); |
| 35 | cachedAudio = null; |
| 36 | } |
| 37 | } |
no test coverage detected