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:
@@ -13,7 +13,7 @@ const State = require('../lib/state')
|
|||||||
const ipcRenderer = electron.ipcRenderer
|
const ipcRenderer = electron.ipcRenderer
|
||||||
|
|
||||||
// Controls playback of torrents and files within torrents
|
// 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 {
|
module.exports = class PlaybackController {
|
||||||
constructor (state, config, update) {
|
constructor (state, config, update) {
|
||||||
this.state = state
|
this.state = state
|
||||||
@@ -242,8 +242,8 @@ module.exports = class PlaybackController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// play in VLC if set as default player (Preferences / Playback / Play in VLC)
|
// play in VLC if set as default player (Preferences / Playback / Play in VLC)
|
||||||
if (this.state.saved.prefs.playInVlc) {
|
if (this.state.saved.prefs.openExternalPlayer) {
|
||||||
dispatch('vlcPlay')
|
dispatch('openExternalPlayer')
|
||||||
this.update()
|
this.update()
|
||||||
cb()
|
cb()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ function run (state) {
|
|||||||
migrate_0_11_0(state.saved)
|
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
|
// Config is now on the new version
|
||||||
state.saved.version = config.APP_VERSION
|
state.saved.version = config.APP_VERSION
|
||||||
}
|
}
|
||||||
@@ -104,3 +108,10 @@ function migrate_0_11_0 (saved) {
|
|||||||
saved.prefs.isFileHandler = true
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -100,7 +100,10 @@ function setupSavedState (cb) {
|
|||||||
|
|
||||||
var saved = {
|
var saved = {
|
||||||
prefs: {
|
prefs: {
|
||||||
downloadPath: config.DEFAULT_DOWNLOAD_PATH
|
downloadPath: config.DEFAULT_DOWNLOAD_PATH,
|
||||||
|
isFileHandler: false,
|
||||||
|
openExternalPlayer: false,
|
||||||
|
externalPlayerPath: null
|
||||||
},
|
},
|
||||||
torrents: config.DEFAULT_TORRENTS.map(createTorrentObject),
|
torrents: config.DEFAULT_TORRENTS.map(createTorrentObject),
|
||||||
version: config.APP_VERSION /* make sure we can upgrade gracefully later */
|
version: config.APP_VERSION /* make sure we can upgrade gracefully later */
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ const dispatchHandlers = {
|
|||||||
'checkForSubtitles': () => controllers.subtitles.checkForSubtitles(),
|
'checkForSubtitles': () => controllers.subtitles.checkForSubtitles(),
|
||||||
'addSubtitles': (files, autoSelect) => controllers.subtitles.addSubtitles(files, autoSelect),
|
'addSubtitles': (files, autoSelect) => controllers.subtitles.addSubtitles(files, autoSelect),
|
||||||
|
|
||||||
// Local media: <video>, <audio>, VLC
|
// Local media: <video>, <audio>, external players
|
||||||
'mediaStalled': () => controllers.media.mediaStalled(),
|
'mediaStalled': () => controllers.media.mediaStalled(),
|
||||||
'mediaError': (err) => controllers.media.mediaError(err),
|
'mediaError': (err) => controllers.media.mediaError(err),
|
||||||
'mediaSuccess': () => controllers.media.mediaSuccess(),
|
'mediaSuccess': () => controllers.media.mediaSuccess(),
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ function renderGeneralSection (state) {
|
|||||||
icon: 'settings'
|
icon: 'settings'
|
||||||
}, [
|
}, [
|
||||||
renderDownloadPathSelector(state),
|
renderDownloadPathSelector(state),
|
||||||
renderFileHandlers(state),
|
renderFileHandlers(state)
|
||||||
renderExternalPlayerSelector(state)
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,24 +35,11 @@ function renderPlaybackSection (state) {
|
|||||||
description: '',
|
description: '',
|
||||||
icon: 'settings'
|
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) {
|
function renderDownloadPathSelector (state) {
|
||||||
return renderFileSelector({
|
return renderFileSelector({
|
||||||
key: 'download-path',
|
key: 'download-path',
|
||||||
@@ -104,7 +90,7 @@ function renderExternalPlayerSelector (state) {
|
|||||||
properties: [ 'openFile' ]
|
properties: [ 'openFile' ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
state.unsaved.prefs.externalPlayerPath || '<VLC>', // TODO: should we get/store vlc path instead?
|
state.unsaved.prefs.externalPlayerPath || '<VLC>',
|
||||||
function (filePath) {
|
function (filePath) {
|
||||||
if (path.extname(filePath) === '.app') {
|
if (path.extname(filePath) === '.app') {
|
||||||
// Get executable in packaged mac 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.
|
// Renders a prefs section.
|
||||||
// - definition should be {icon, title, description}
|
// - definition should be {icon, title, description}
|
||||||
// - controls should be an array of vdom elements
|
// - controls should be an array of vdom elements
|
||||||
|
|||||||
Reference in New Issue
Block a user