diff --git a/electron/api.ts b/electron/api.ts
index 2b56d57cb..4002108f8 100644
--- a/electron/api.ts
+++ b/electron/api.ts
@@ -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
diff --git a/shared/ipc-commands.ts b/shared/ipc-commands.ts
index 1a57b142b..f3a063276 100644
--- a/shared/ipc-commands.ts
+++ b/shared/ipc-commands.ts
@@ -44,6 +44,8 @@ export const AUTO_UPDATE_PLAYLISTS_RESPONSE = 'AUTO_UPDATE_RESPONSE';
// Experimental
export const OPEN_MPV_PLAYER = 'OPEN_MPV_PLAYER';
export const SET_MPV_PLAYER_PATH = 'SET_MPV_PLAYER_PATH';
+export const OPEN_VLC_PLAYER = 'OPEN_VLC_PLAYER';
+export const SET_VLC_PLAYER_PATH = 'SET_VLC_PLAYER_PATH';
// Xtream
export const XTREAM_REQUEST = 'XTREAM_REQUEST';
diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html
index 9a3704d21..d899cbc38 100644
--- a/src/app/settings/settings.component.html
+++ b/src/app/settings/settings.component.html
@@ -110,6 +110,26 @@
{{ 'SETTINGS.VLC_PLAYER_PATH_DESCRIPTION' | translate }}
+