External VLC on Windows
Turns out we can't use vlc --version because it pops up a command prompt :/
This commit is contained in:
@@ -92,9 +92,9 @@ function init () {
|
|||||||
windows.focusWindow(windows[windowName])
|
windows.focusWindow(windows[windowName])
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('vlcVersion', function (e) {
|
ipcMain.on('checkForVLC', function (e) {
|
||||||
vlc.getInstalledVersion(function (version) {
|
vlc.checkForVLC(function (isInstalled) {
|
||||||
windows.main.send('vlcVersion', version)
|
windows.main.send('checkForVLC', isInstalled)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
28
main/vlc.js
28
main/vlc.js
@@ -1,33 +1,15 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
getInstalledVersion,
|
checkForVLC,
|
||||||
spawn
|
spawn
|
||||||
}
|
}
|
||||||
|
|
||||||
var cp = require('child_process')
|
var cp = require('child_process')
|
||||||
var vlcCommand = require('vlc-command')
|
var vlcCommand = require('vlc-command')
|
||||||
|
|
||||||
// Runs vlc --version. Calls back with the currently installed version of VLC
|
// Finds if VLC is installed on Mac, Windows, or Linux.
|
||||||
// or null if VLC is not installed. (Or 'unknown' if VLC runs and produces bad
|
// Calls back with true or false: whether VLC was detected
|
||||||
// output, but that should never happen.)
|
function checkForVLC (cb) {
|
||||||
function getInstalledVersion (cb) {
|
vlcCommand((err) => cb(!err))
|
||||||
exec(['--version'], function (e, stdout) {
|
|
||||||
var version
|
|
||||||
if (e) {
|
|
||||||
version = null
|
|
||||||
} else {
|
|
||||||
// Prints several lines, starting with eg: VLC media player 2.7.0
|
|
||||||
if (!stdout.startsWith('VLC media player')) version = 'unknown'
|
|
||||||
else version = stdout.split(' ')[3]
|
|
||||||
}
|
|
||||||
cb(version)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function exec (args, cb) {
|
|
||||||
vlcCommand(function (err, vlcPath) {
|
|
||||||
if (err) return cb(err)
|
|
||||||
cp.execFile(vlcPath, args, cb)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finds if VLC is installed on Mac, Windows, or Linux.
|
// Finds if VLC is installed on Mac, Windows, or Linux.
|
||||||
|
|||||||
@@ -306,13 +306,12 @@ function dispatch (action, ...args) {
|
|||||||
if (action === 'mediaError') {
|
if (action === 'mediaError') {
|
||||||
if (state.location.current().url === 'player') {
|
if (state.location.current().url === 'player') {
|
||||||
state.playing.location = 'error'
|
state.playing.location = 'error'
|
||||||
ipcRenderer.send('vlcVersion')
|
ipcRenderer.send('checkForVLC')
|
||||||
ipcRenderer.once('vlcVersion', function (e, version) {
|
ipcRenderer.once('checkForVLC', function (e, isInstalled) {
|
||||||
console.log('vlcVersion', version)
|
|
||||||
state.modal = {
|
state.modal = {
|
||||||
id: 'unsupported-media-modal',
|
id: 'unsupported-media-modal',
|
||||||
error: args[0],
|
error: args[0],
|
||||||
vlcInstalled: !!version
|
vlcInstalled: isInstalled
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user