diff --git a/src/renderer/controllers/playback-controller.js b/src/renderer/controllers/playback-controller.js index 8df16af9..397b0e12 100644 --- a/src/renderer/controllers/playback-controller.js +++ b/src/renderer/controllers/playback-controller.js @@ -241,12 +241,19 @@ module.exports = class PlaybackController { return this.update() } + // play in VLC if set as default player (Preferences / Playback / Play in VLC) + if (this.state.saved.prefs.playInVlc) { + dispatch('vlcPlay') + this.update() + cb() + return + } + // otherwise, play the video state.window.title = torrentSummary.files[state.playing.fileIndex].name this.update() ipcRenderer.send('onPlayerOpen') - cb() }) } diff --git a/src/renderer/views/preferences.js b/src/renderer/views/preferences.js index c4d2feba..594d803d 100644 --- a/src/renderer/views/preferences.js +++ b/src/renderer/views/preferences.js @@ -10,6 +10,7 @@ module.exports = class Preferences extends React.Component { return (
{renderGeneralSection(state)} + {renderPlaybackSection(state)}
) } @@ -27,6 +28,30 @@ function renderGeneralSection (state) { ]) } +function renderPlaybackSection (state) { + return renderSection({ + title: 'Playback', + description: '', + icon: 'settings' + }, [ + renderPlayInVlcSelector(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', @@ -91,6 +116,35 @@ function renderSection (definition, controls) { ) } +function renderCheckbox (definition, value, callback) { + var iconClass = 'icon clickable' + if (value) iconClass += ' enabled' + + return ( +
+
+ +
+ +
+
+
+ ) + function handleClick () { + callback(!value) + } +} + // Creates a file chooser // - defition should be {label, description, options} // options are passed to dialog.showOpenDialog diff --git a/static/main.css b/static/main.css index a2b1a8b7..e42dd878 100644 --- a/static/main.css +++ b/static/main.css @@ -122,6 +122,10 @@ table { * UTILITY CLASSES */ +.clickable { + cursor: pointer; +} + .ellipsis { overflow: hidden; text-overflow: ellipsis; @@ -932,6 +936,10 @@ video::-webkit-media-text-track-container { margin-right: 0.2em; } +.preferences .icon.enabled { + color: yellow; +} + .preferences .btn { display: inline-block; -webkit-appearance: button; @@ -1079,6 +1087,14 @@ video::-webkit-media-text-track-container { vertical-align: text-bottom; } +.preferences .checkbox { + width: auto; +} + +.checkbox-label { + vertical-align: top; +} + /* * MEDIA OVERLAY / AUDIO DETAILS