feat: enhance sound playback in InviteNotifications and MessageNotifications for Electron support

This commit is contained in:
2026-04-02 22:40:48 +11:00
parent b3495bc102
commit 6e1df928ad

View File

@@ -150,12 +150,13 @@ function InviteNotifications() {
); );
const playSound = useCallback(() => { const playSound = useCallback(() => {
console.log('[InviteNotifications] playSound called'); if (isElectron() && (window as any).electron?.audio?.playNotificationSound) {
// Use HTML5 Audio - works reliably in Chromium/Electron (supports OGG) (window as any).electron.audio.playNotificationSound('invite');
const audio = new Audio('/sound/invite.ogg'); } else {
audio.play().catch((err) => { new Audio('./sound/invite.ogg').play().catch((err) => {
console.error('[Audio] Failed to play invite sound:', err); console.error('[Audio] Failed to play invite sound:', err);
}); });
}
}, []); }, []);
useEffect(() => { useEffect(() => {
@@ -295,13 +296,13 @@ function MessageNotifications() {
); );
const playSound = useCallback(() => { const playSound = useCallback(() => {
console.log('[MessageNotifications] playSound called'); if (isElectron() && (window as any).electron?.audio?.playNotificationSound) {
// Use HTML5 Audio - works reliably in Chromium/Electron (supports OGG) (window as any).electron.audio.playNotificationSound('message');
// Main process audio is unreliable on Windows (can't play OGG natively) } else {
const audio = new Audio('/sound/notification.ogg'); new Audio('./sound/notification.ogg').play().catch((err) => {
audio.play().catch((err) => {
console.error('[Audio] Failed to play notification sound:', err); console.error('[Audio] Failed to play notification sound:', err);
}); });
}
}, []); }, []);
useEffect(() => { useEffect(() => {