Fixes to PR #682

- Rename 'playInVlc' preference to 'openExternalPlayer' since we
support more than just VLC now.
- Add default pref options to state.js
This commit is contained in:
Feross Aboukhadijeh
2016-08-20 01:19:50 -07:00
parent 667a04a41d
commit 2d3673ea33
5 changed files with 37 additions and 23 deletions

View File

@@ -13,7 +13,7 @@ const State = require('../lib/state')
const ipcRenderer = electron.ipcRenderer
// Controls playback of torrents and files within torrents
// both local (<video>,<audio>,VLC) and remote (cast)
// both local (<video>,<audio>,external player) and remote (cast)
module.exports = class PlaybackController {
constructor (state, config, update) {
this.state = state
@@ -242,8 +242,8 @@ module.exports = class PlaybackController {
}
// play in VLC if set as default player (Preferences / Playback / Play in VLC)
if (this.state.saved.prefs.playInVlc) {
dispatch('vlcPlay')
if (this.state.saved.prefs.openExternalPlayer) {
dispatch('openExternalPlayer')
this.update()
cb()
return

View File

@@ -29,6 +29,10 @@ function run (state) {
migrate_0_11_0(state.saved)
}
if (semver.lt(version, '0.12.0')) {
migrate_0_12_0(state.saved)
}
// Config is now on the new version
state.saved.version = config.APP_VERSION
}
@@ -104,3 +108,10 @@ function migrate_0_11_0 (saved) {
saved.prefs.isFileHandler = true
}
}
function migrate_0_12_0 (saved) {
if (saved.prefs.openExternalPlayer == null && saved.prefs.playInVlc != null) {
saved.prefs.openExternalPlayer = saved.prefs.playInVlc
}
delete saved.prefs.playInVlc
}

View File

@@ -100,7 +100,10 @@ function setupSavedState (cb) {
var saved = {
prefs: {
downloadPath: config.DEFAULT_DOWNLOAD_PATH
downloadPath: config.DEFAULT_DOWNLOAD_PATH,
isFileHandler: false,
openExternalPlayer: false,
externalPlayerPath: null
},
torrents: config.DEFAULT_TORRENTS.map(createTorrentObject),
version: config.APP_VERSION /* make sure we can upgrade gracefully later */

View File

@@ -198,7 +198,7 @@ const dispatchHandlers = {
'checkForSubtitles': () => controllers.subtitles.checkForSubtitles(),
'addSubtitles': (files, autoSelect) => controllers.subtitles.addSubtitles(files, autoSelect),
// Local media: <video>, <audio>, VLC
// Local media: <video>, <audio>, external players
'mediaStalled': () => controllers.media.mediaStalled(),
'mediaError': (err) => controllers.media.mediaError(err),
'mediaSuccess': () => controllers.media.mediaSuccess(),

View File

@@ -25,8 +25,7 @@ function renderGeneralSection (state) {
icon: 'settings'
}, [
renderDownloadPathSelector(state),
renderFileHandlers(state),
renderExternalPlayerSelector(state)
renderFileHandlers(state)
])
}
@@ -36,24 +35,11 @@ function renderPlaybackSection (state) {
description: '',
icon: 'settings'
}, [
renderPlayInVlcSelector(state)
renderOpenExternalPlayerSelector(state),
renderExternalPlayerSelector(state)
])
}
function renderPlayInVlcSelector (state) {
return renderCheckbox({
key: 'play-in-vlc',
label: 'Play in VLC',
description: 'Media will play in VLC',
property: 'playInVlc',
value: state.saved.prefs.playInVlc
},
state.unsaved.prefs.playInVlc,
function (value) {
dispatch('updatePreferences', 'playInVlc', value)
})
}
function renderDownloadPathSelector (state) {
return renderFileSelector({
key: 'download-path',
@@ -104,7 +90,7 @@ function renderExternalPlayerSelector (state) {
properties: [ 'openFile' ]
}
},
state.unsaved.prefs.externalPlayerPath || '<VLC>', // TODO: should we get/store vlc path instead?
state.unsaved.prefs.externalPlayerPath || '<VLC>',
function (filePath) {
if (path.extname(filePath) === '.app') {
// Get executable in packaged mac app
@@ -115,6 +101,20 @@ function renderExternalPlayerSelector (state) {
})
}
function renderOpenExternalPlayerSelector (state) {
return renderCheckbox({
key: 'open-external-player',
label: 'Play in External Player',
description: 'Media will play in external player',
property: 'openExternalPlayer',
value: state.saved.prefs.openExternalPlayer
},
state.unsaved.prefs.openExternalPlayer,
function (value) {
dispatch('updatePreferences', 'openExternalPlayer', value)
})
}
// Renders a prefs section.
// - definition should be {icon, title, description}
// - controls should be an array of vdom elements