mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-14 05:06:16 -08:00
refactor(player,epg): add MPV reuse, IPC commands, and EPG handlers
Introduce MPV process reuse and IPC control, and add basic EPG IPC
handlers.
- Add GET_CHANNEL_PROGRAMS and FETCH_EPG ipc handlers to epg.events.ts
to expose fetching EPG data by channel or URLs.
- Rework player.events.ts:
- Export proper bootstrap and add module-level mpvProcess and
mpvSocketPath to track a reusable MPV instance.
- Add sendMpvCommand helper to communicate with MPV via its IPC socket.
- Implement OPEN_MPV_PLAYER handler that:
- Reads MPV path and MPV_REUSE_INSTANCE setting from store.
- Attempts to reuse an existing MPV process by sending loadfile
command over the socket when reuse is enabled.
- Falls back to spawning a new mpv process, creating a unique IPC
socket path, and storing the process/socket when reuse is enabled.
- Adds error and exit handlers to clear stored references.
- Add necessary imports (ChildProcess, existsSync, createConnection).
- Remove/comment unused import block for shared-interfaces and adapt
existing code to the new flow.
Why:
- Enable reusing a single MPV instance to improve resource usage and
provide faster playback switching.
- Add IPC endpoints for EPG to support frontend requests for program
data.
This commit is contained in:
1 parent
b61530f279
commit
d9cbb1ce87
7 files changed
+291
-56
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import { contextBridge, ipcRenderer } from 'electron';
|
||||
import { AUTO_UPDATE_PLAYLISTS, Playlist } from 'shared-interfaces';
|
||||
|
||||
contextBridge.exposeInMainWorld('electron', {
|
||||
getAppVersion: () => ipcRenderer.invoke('get-app-version'),
|
||||
@@ -10,7 +9,7 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
ipcRenderer.invoke('update-playlist-from-file-path', filePath, title),
|
||||
openPlaylistFromFile: () => ipcRenderer.invoke('open-playlist-from-file'),
|
||||
setUserAgent: (userAgent: string, referer?: string) =>
|
||||
ipcRenderer.send('set-user-agent', userAgent, referer),
|
||||
ipcRenderer.invoke('set-user-agent', userAgent, referer),
|
||||
openInMpv: (
|
||||
url: string,
|
||||
path: string,
|
||||
@@ -19,8 +18,8 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
referer?: string,
|
||||
origin?: string
|
||||
) =>
|
||||
ipcRenderer.send(
|
||||
'open-in-mpv',
|
||||
ipcRenderer.invoke(
|
||||
'OPEN_MPV_PLAYER',
|
||||
url,
|
||||
path,
|
||||
title,
|
||||
@@ -36,8 +35,8 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
referer?: string,
|
||||
origin?: string
|
||||
) =>
|
||||
ipcRenderer.send(
|
||||
'open-in-vlc',
|
||||
ipcRenderer.invoke(
|
||||
'OPEN_VLC_PLAYER',
|
||||
url,
|
||||
path,
|
||||
title,
|
||||
@@ -45,6 +44,16 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
referer,
|
||||
origin
|
||||
),
|
||||
autoUpdatePlaylists: (playlists: Playlist[]) =>
|
||||
ipcRenderer.send(AUTO_UPDATE_PLAYLISTS, playlists),
|
||||
autoUpdatePlaylists: (playlists) =>
|
||||
ipcRenderer.invoke('AUTO_UPDATE_PLAYLISTS', playlists),
|
||||
fetchEpg: (urls: string[]) =>
|
||||
ipcRenderer.invoke('FETCH_EPG', { url: urls }),
|
||||
getChannelPrograms: (channelId: string) =>
|
||||
ipcRenderer.invoke('GET_CHANNEL_PROGRAMS', { channelId }),
|
||||
setMpvPlayerPath: (mpvPlayerPath: string) =>
|
||||
ipcRenderer.invoke('SET_MPV_PLAYER_PATH', mpvPlayerPath),
|
||||
setVlcPlayerPath: (vlcPlayerPath: string) =>
|
||||
ipcRenderer.invoke('SET_VLC_PLAYER_PATH', vlcPlayerPath),
|
||||
updateSettings: (settings: any) =>
|
||||
ipcRenderer.invoke('SETTINGS_UPDATE', settings),
|
||||
});
|
||||
Reference in new issue
Block a user