Merge branch 'external-player' of https://github.com/mathiasvr/webtorrent-desktop into mathiasvr-external-player

Fixed conflicts in the Preferences page, and added back passing the video title to VLC
This commit is contained in:
Feross Aboukhadijeh
2016-08-19 22:06:23 -07:00
9 changed files with 126 additions and 88 deletions

View File

@@ -2,6 +2,7 @@ const React = require('react')
const Bitfield = require('bitfield')
const prettyBytes = require('prettier-bytes')
const zeroFill = require('zero-fill')
const path = require('path')
const TorrentSummary = require('../lib/torrent-summary')
const {dispatch, dispatcher} = require('../lib/dispatcher')
@@ -281,9 +282,12 @@ function renderCastScreen (state) {
castIcon = 'tv'
castType = 'DLNA'
isCast = true
} else if (state.playing.location === 'vlc') {
} else if (state.playing.location === 'external') {
// TODO: get the player name in a more reliable way
var playerPath = state.saved.prefs.externalPlayerPath
var playerName = playerPath ? path.basename(playerPath).split('.')[0] : 'VLC'
castIcon = 'tv'
castType = 'VLC'
castType = playerName
isCast = false
} else if (state.playing.location === 'error') {
castIcon = 'error_outline'

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')
@@ -24,7 +25,8 @@ function renderGeneralSection (state) {
icon: 'settings'
}, [
renderDownloadPathSelector(state),
renderFileHandlers(state)
renderFileHandlers(state),
renderExternalPlayerSelector(state)
])
}
@@ -92,6 +94,27 @@ function renderFileHandlers (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
}
dispatch('updatePreferences', 'externalPlayerPath', filePath)
})
}
// Renders a prefs section.
// - definition should be {icon, title, description}
// - controls should be an array of vdom elements

View File

@@ -1,5 +1,6 @@
const React = require('react')
const electron = require('electron')
const path = require('path')
const {dispatcher} = require('../lib/dispatcher')
@@ -10,11 +11,15 @@ module.exports = class UnsupportedMediaModal extends React.Component {
var message = (err && err.getMessage)
? err.getMessage()
: err
var actionButton = state.modal.vlcInstalled
? (<button className='button-raised' onClick={dispatcher('vlcPlay')}>Play in VLC</button>)
var playerPath = state.saved.prefs.externalPlayerPath
var playerName = playerPath
? path.basename(playerPath).split('.')[0]
: 'VLC'
var actionButton = state.modal.externalPlayerInstalled
? (<button className='button-raised' onClick={dispatcher('openExternalPlayer')}>Play in {playerName}</button>)
: (<button className='button-raised' onClick={() => this.onInstall}>Install VLC</button>)
var vlcMessage = state.modal.vlcNotFound
? 'Couldn\'t run VLC. Please make sure it\'s installed.'
var playerMessage = state.modal.externalPlayerNotFound
? 'Couldn\'t run external player. Please make sure it\'s installed.'
: ''
return (
<div>
@@ -24,7 +29,7 @@ module.exports = class UnsupportedMediaModal extends React.Component {
<button className='button-flat' onClick={dispatcher('backToList')}>Cancel</button>
{actionButton}
</p>
<p className='error-text'>{vlcMessage}</p>
<p className='error-text'>{playerMessage}</p>
</div>
)
}
@@ -34,6 +39,6 @@ module.exports = class UnsupportedMediaModal extends React.Component {
// TODO: dcposch send a dispatch rather than modifying state directly
var state = this.props.state
state.modal.vlcInstalled = true // Assume they'll install it successfully
state.modal.externalPlayerInstalled = true // Assume they'll install it successfully
}
}