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(() => {
|
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(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user