mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
feat: add experimental vlc player support
This commit is contained in:
1 parent
70675f98e9
commit
2a9123781f
6 files changed
+98
-11
No files matched your search
@@ -25,11 +25,13 @@ import {
|
||||
MIGRATE_PLAYLISTS_RESPONSE,
|
||||
OPEN_FILE,
|
||||
OPEN_MPV_PLAYER,
|
||||
OPEN_VLC_PLAYER,
|
||||
PLAYLIST_PARSE_BY_URL,
|
||||
PLAYLIST_PARSE_RESPONSE,
|
||||
PLAYLIST_UPDATE,
|
||||
PLAYLIST_UPDATE_RESPONSE,
|
||||
SET_MPV_PLAYER_PATH,
|
||||
SET_VLC_PLAYER_PATH,
|
||||
XTREAM_REQUEST,
|
||||
XTREAM_RESPONSE,
|
||||
} from '../shared/ipc-commands';
|
||||
@@ -39,6 +41,8 @@ import { ParsedPlaylist } from '../src/typings.d';
|
||||
|
||||
const fs = require('fs');
|
||||
const https = require('https');
|
||||
const child_process = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
const mpvAPI = require('node-mpv');
|
||||
|
||||
@@ -63,6 +67,7 @@ const agent = new https.Agent({
|
||||
});
|
||||
|
||||
const MPV_PLAYER_PATH = 'MPV_PLAYER_PATH';
|
||||
const VLC_PLAYER_PATH = 'VLC_PLAYER_PATH';
|
||||
|
||||
export class Api {
|
||||
/** Instance of the main application window */
|
||||
@@ -254,6 +259,24 @@ export class Api {
|
||||
// recreate mpv player instance with new binary path if it was changed
|
||||
if (store.get(MPV_PLAYER_PATH, mpvPlayerPath) !== mpvPlayerPath)
|
||||
this.mpv = this.createMpvInstance();
|
||||
})
|
||||
.on(OPEN_VLC_PLAYER, (event, { url }) => {
|
||||
const proc = child_process.spawn(
|
||||
this.getVlcPath(),
|
||||
[`"${url as string}"`],
|
||||
{
|
||||
shell: true,
|
||||
}
|
||||
);
|
||||
|
||||
proc.on('exit', (code) => {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
console.log(`VLC exited with code ${code}`);
|
||||
});
|
||||
})
|
||||
.on(SET_VLC_PLAYER_PATH, (_event, vlcPlayerPath) => {
|
||||
console.log('... setting vlc player path', vlcPlayerPath);
|
||||
store.set(VLC_PLAYER_PATH, vlcPlayerPath);
|
||||
});
|
||||
|
||||
// listeners for EPG events
|
||||
@@ -503,6 +526,31 @@ export class Api {
|
||||
return parse(m3uString);
|
||||
}
|
||||
|
||||
getDefaultVlcPath() {
|
||||
if (process.platform === 'win32') {
|
||||
return path.join(
|
||||
'C:',
|
||||
'Program Files (x86)',
|
||||
'VideoLAN',
|
||||
'VLC',
|
||||
'vlc.exe'
|
||||
);
|
||||
} else if (process.platform === 'linux') {
|
||||
return '/usr/bin/vlc';
|
||||
} else if (process.platform === 'darwin') {
|
||||
return '/Applications/VLC.app/Contents/MacOS/VLC';
|
||||
}
|
||||
}
|
||||
|
||||
getVlcPath() {
|
||||
const customVlcPath = this.store.get(VLC_PLAYER_PATH);
|
||||
if (customVlcPath) {
|
||||
return customVlcPath;
|
||||
} else {
|
||||
return this.getDefaultVlcPath();
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated - used only for migration */
|
||||
getAllPlaylists() {
|
||||
return db
|
||||
|
||||
Reference in new issue
Block a user