mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 18:13:31 +00:00
Force quit mpv on app close (#4)
This commit is contained in:
parent
b6fd3a4f66
commit
4614358163
4 changed files with 34 additions and 6 deletions
|
|
@ -44,7 +44,7 @@ const mpv = new MpvAPI(
|
|||
);
|
||||
|
||||
mpv.start().catch((error) => {
|
||||
console.log('error', error);
|
||||
console.log('error starting mpv', error);
|
||||
});
|
||||
|
||||
mpv.on('status', (status) => {
|
||||
|
|
@ -152,10 +152,14 @@ ipcMain.on('player-auto-next', async (_event, data: PlayerData) => {
|
|||
|
||||
// Sets the volume to the given value (0-100)
|
||||
ipcMain.on('player-volume', async (_event, value: number) => {
|
||||
mpv.volume(value);
|
||||
await mpv.volume(value);
|
||||
});
|
||||
|
||||
// Toggles the mute status
|
||||
ipcMain.on('player-mute', async () => {
|
||||
mpv.mute();
|
||||
await mpv.mute();
|
||||
});
|
||||
|
||||
ipcMain.on('player-quit', async () => {
|
||||
await mpv.quit();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -165,6 +165,10 @@ export const getMainWindow = () => {
|
|||
return mainWindow;
|
||||
};
|
||||
|
||||
app.on('before-quit', () => {
|
||||
mainWindow?.webContents.send('renderer-player-quit');
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
// Respect the OSX convention of having the application in memory even
|
||||
// after all windows have been closed
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ const volume = (value: number) => {
|
|||
ipcRenderer.send('player-volume', value);
|
||||
};
|
||||
|
||||
const quit = () => {
|
||||
ipcRenderer.send('player-quit');
|
||||
};
|
||||
|
||||
const rendererAutoNext = (cb: (event: IpcRendererEvent, data: PlayerData) => void) => {
|
||||
ipcRenderer.on('renderer-player-auto-next', cb);
|
||||
};
|
||||
|
|
@ -74,6 +78,10 @@ const rendererStop = (cb: (event: IpcRendererEvent, data: PlayerData) => void) =
|
|||
ipcRenderer.on('renderer-player-stop', cb);
|
||||
};
|
||||
|
||||
const rendererQuit = (cb: (event: IpcRendererEvent) => void) => {
|
||||
ipcRenderer.on('renderer-player-quit', cb);
|
||||
};
|
||||
|
||||
export const mpvPlayer = {
|
||||
autoNext,
|
||||
currentTime,
|
||||
|
|
@ -82,6 +90,7 @@ export const mpvPlayer = {
|
|||
pause,
|
||||
play,
|
||||
previous,
|
||||
quit,
|
||||
seek,
|
||||
seekTo,
|
||||
setQueue,
|
||||
|
|
@ -98,5 +107,6 @@ export const mpvPlayerListener = {
|
|||
rendererPlay,
|
||||
rendererPlayPause,
|
||||
rendererPrevious,
|
||||
rendererQuit,
|
||||
rendererStop,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue