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