feat: add sound resource handling and IPC for sound URL retrieval
Some checks failed
Build / increment-version (push) Successful in 7s
Build / build-linux (push) Successful in 1m56s
Build / build-windows (push) Successful in 5m16s
Build Paarrot Windows / start-vm (push) Failing after 5m33s
Build Paarrot Windows / build (push) Has been skipped
Build / create-release (push) Successful in 17s
Some checks failed
Build / increment-version (push) Successful in 7s
Build / build-linux (push) Successful in 1m56s
Build / build-windows (push) Successful in 5m16s
Build Paarrot Windows / start-vm (push) Failing after 5m33s
Build Paarrot Windows / build (push) Has been skipped
Build / create-release (push) Successful in 17s
This commit is contained in:
2
cinny
2
cinny
Submodule cinny updated: fe193bb062...f64ce6168d
@@ -28,6 +28,11 @@
|
||||
"from": "icons",
|
||||
"to": "icons",
|
||||
"filter": ["**/*"]
|
||||
},
|
||||
{
|
||||
"from": "cinny/public/sound",
|
||||
"to": "sound",
|
||||
"filter": ["**/*"]
|
||||
}
|
||||
],
|
||||
"linux": {
|
||||
|
||||
@@ -841,6 +841,11 @@ ipcMain.handle('write-clipboard-text', async (event, text) => {
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('get-sound-base-url', () => {
|
||||
if (isDev) return null; // renderer uses ./sound/ relative path in dev
|
||||
return `file://${path.join(process.resourcesPath, 'sound').replace(/\\/g, '/')}`;
|
||||
});
|
||||
|
||||
// Play notification sound via the renderer's Chromium audio engine.
|
||||
// Chromium has native OGG support on all platforms, so this is always reliable.
|
||||
ipcMain.handle('play-notification-sound', async (event, soundType = 'message') => {
|
||||
@@ -848,9 +853,14 @@ ipcMain.handle('play-notification-sound', async (event, soundType = 'message') =
|
||||
return { success: false, error: 'No main window' };
|
||||
}
|
||||
const soundFile = soundType === 'invite' ? 'invite.ogg' : 'notification.ogg';
|
||||
// In dev, Vite serves sounds via HTTP so relative path works.
|
||||
// In production, sounds are in resources/sound/ as plain files (extraResources).
|
||||
const audioSrc = isDev
|
||||
? `./sound/${soundFile}`
|
||||
: `file://${path.join(process.resourcesPath, 'sound', soundFile).replace(/\\/g, '/')}`;
|
||||
try {
|
||||
await mainWindow.webContents.executeJavaScript(
|
||||
`new Audio('./sound/${soundFile}').play().catch(() => {}); true;`
|
||||
`new Audio('${audioSrc}').play().catch(() => {}); true;`
|
||||
);
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
|
||||
@@ -105,7 +105,8 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
},
|
||||
// Audio
|
||||
audio: {
|
||||
playNotificationSound: (soundType = 'message') => ipcRenderer.invoke('play-notification-sound', soundType)
|
||||
playNotificationSound: (soundType = 'message') => ipcRenderer.invoke('play-notification-sound', soundType),
|
||||
getSoundBaseUrl: () => ipcRenderer.invoke('get-sound-base-url'),
|
||||
},
|
||||
// External URLs
|
||||
shell: {
|
||||
|
||||
Reference in New Issue
Block a user