Custom external media player

This commit is contained in:
Mathias Rasmussen
2016-06-27 22:11:05 +02:00
parent 1605d23509
commit 6c68645b0f
9 changed files with 126 additions and 88 deletions

View File

@@ -1,6 +1,7 @@
const React = require('react')
const remote = require('electron').remote
const dialog = remote.dialog
const path = require('path')
const {dispatch} = require('../lib/dispatcher')
@@ -22,7 +23,8 @@ function renderGeneralSection (state) {
description: '',
icon: 'settings'
}, [
renderDownloadDirSelector(state)
renderDownloadDirSelector(state),
renderExternalPlayerSelector(state)
])
}
@@ -43,6 +45,27 @@ function renderDownloadDirSelector (state) {
})
}
function renderExternalPlayerSelector (state) {
return renderFileSelector({
label: 'External Media Player',
description: 'Progam that will be used to play media externally',
property: 'externalPlayerPath',
options: {
title: 'Select media player executable',
properties: [ 'openFile' ]
}
},
state.unsaved.prefs.externalPlayerPath || '<VLC>', // TODO: should we get/store vlc path instead?
function (filePath) {
if (path.extname(filePath) === '.app') {
// Get executable in packaged mac app
var name = path.basename(filePath, '.app')
filePath += '/Contents/MacOS/' + name
}
setStateValue('externalPlayerPath', filePath)
})
}
// Renders a prefs section.
// - definition should be {icon, title, description}
// - controls should be an array of vdom elements