feat: enhance sound playback in InviteNotifications and MessageNotifications with logging and error handling
This commit is contained in:
@@ -150,9 +150,14 @@ function InviteNotifications() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const playSound = useCallback(() => {
|
const playSound = useCallback(() => {
|
||||||
|
console.log('[InviteNotifications] playSound called, isElectron:', isElectron());
|
||||||
if (isElectron() && (window as any).electron?.audio?.playNotificationSound) {
|
if (isElectron() && (window as any).electron?.audio?.playNotificationSound) {
|
||||||
(window as any).electron.audio.playNotificationSound('invite');
|
console.log('[InviteNotifications] Using Electron audio API');
|
||||||
|
(window as any).electron.audio.playNotificationSound('invite')
|
||||||
|
.then((result: any) => console.log('[InviteNotifications] Sound result:', result))
|
||||||
|
.catch((err: any) => console.error('[InviteNotifications] Sound error:', err));
|
||||||
} else {
|
} else {
|
||||||
|
console.log('[InviteNotifications] Using HTML5 Audio fallback');
|
||||||
new Audio('./sound/invite.ogg').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);
|
||||||
});
|
});
|
||||||
@@ -296,9 +301,14 @@ function MessageNotifications() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const playSound = useCallback(() => {
|
const playSound = useCallback(() => {
|
||||||
|
console.log('[MessageNotifications] playSound called, isElectron:', isElectron());
|
||||||
if (isElectron() && (window as any).electron?.audio?.playNotificationSound) {
|
if (isElectron() && (window as any).electron?.audio?.playNotificationSound) {
|
||||||
(window as any).electron.audio.playNotificationSound('message');
|
console.log('[MessageNotifications] Using Electron audio API');
|
||||||
|
(window as any).electron.audio.playNotificationSound('message')
|
||||||
|
.then((result: any) => console.log('[MessageNotifications] Sound result:', result))
|
||||||
|
.catch((err: any) => console.error('[MessageNotifications] Sound error:', err));
|
||||||
} else {
|
} else {
|
||||||
|
console.log('[MessageNotifications] Using HTML5 Audio fallback');
|
||||||
new Audio('./sound/notification.ogg').play().catch((err) => {
|
new Audio('./sound/notification.ogg').play().catch((err) => {
|
||||||
console.error('[Audio] Failed to play notification sound:', err);
|
console.error('[Audio] Failed to play notification sound:', err);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user