mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 02:13:33 +00:00
Refactor mpv initialization/cleanup
- Don't re-initialize the player on re-render - Fixes the player potentially crashing on hot reload
This commit is contained in:
parent
d97fe4c621
commit
c3c1f4cc5f
5 changed files with 157 additions and 52 deletions
|
|
@ -9,6 +9,14 @@ const restart = (data: { extraParameters?: string[]; properties?: Record<string,
|
|||
ipcRenderer.send('player-restart', data);
|
||||
};
|
||||
|
||||
const isRunning = () => {
|
||||
return ipcRenderer.invoke('player-is-running');
|
||||
};
|
||||
|
||||
const cleanup = () => {
|
||||
return ipcRenderer.invoke('player-clean-up');
|
||||
};
|
||||
|
||||
const setProperties = (data: Record<string, any>) => {
|
||||
console.log('Setting property :>>', data);
|
||||
ipcRenderer.send('player-set-properties', data);
|
||||
|
|
@ -160,9 +168,11 @@ const rendererError = (cb: (event: IpcRendererEvent, data: string) => void) => {
|
|||
|
||||
export const mpvPlayer = {
|
||||
autoNext,
|
||||
cleanup,
|
||||
currentTime,
|
||||
getCurrentTime,
|
||||
initialize,
|
||||
isRunning,
|
||||
mute,
|
||||
next,
|
||||
pause,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue