diff --git a/src/renderer/controllers/media-controller.js b/src/renderer/controllers/media-controller.js index 88b744a4..b22a699c 100644 --- a/src/renderer/controllers/media-controller.js +++ b/src/renderer/controllers/media-controller.js @@ -56,7 +56,10 @@ module.exports = class MediaController { const state = this.state state.playing.location = 'external' - let open = function () { + const onServerRunning = function () { + state.playing.isReady = true + telemetry.logPlayAttempt('external') + const mediaURL = Playlist.getCurrentLocalURL(state) ipcRenderer.send('openExternalPlayer', state.saved.prefs.externalPlayerPath, @@ -64,8 +67,8 @@ module.exports = class MediaController { state.window.title) } - if (state.server != null) open() - else ipcRenderer.once('wt-server-running', open) + if (state.server != null) onServerRunning() + else ipcRenderer.once('wt-server-running', onServerRunning) } externalPlayerNotFound () { diff --git a/src/renderer/controllers/playback-controller.js b/src/renderer/controllers/playback-controller.js index 0c24157e..7acfb90e 100644 --- a/src/renderer/controllers/playback-controller.js +++ b/src/renderer/controllers/playback-controller.js @@ -223,6 +223,8 @@ module.exports = class PlaybackController { // Starts WebTorrent server for media streaming startServer (torrentSummary) { + const state = this.state + if (torrentSummary.status === 'paused') { dispatch('startTorrentingSummary', torrentSummary.torrentKey) ipcRenderer.once('wt-ready-' + torrentSummary.infoHash, @@ -233,7 +235,7 @@ module.exports = class PlaybackController { function onTorrentReady () { ipcRenderer.send('wt-start-server', torrentSummary.infoHash) - ipcRenderer.once('wt-server-running', () => state.playing.isReady = true) + ipcRenderer.once('wt-server-running', () => { state.playing.isReady = true }) } } diff --git a/src/renderer/lib/state.js b/src/renderer/lib/state.js index dc45daa5..1bd9bcd3 100644 --- a/src/renderer/lib/state.js +++ b/src/renderer/lib/state.js @@ -91,7 +91,7 @@ function getDefaultPlayState () { location: 'local', /* 'local', 'chromecast', 'airplay' */ type: null, /* 'audio' or 'video', could be 'other' if ever support eg streaming to VLC */ currentTime: 0, /* seconds */ - duration: 1, /* seconds */, + duration: 1, /* seconds */ isReady: false, isPaused: true, isStalled: false, diff --git a/src/renderer/lib/telemetry.js b/src/renderer/lib/telemetry.js index 48ab4757..c18437c8 100644 --- a/src/renderer/lib/telemetry.js +++ b/src/renderer/lib/telemetry.js @@ -67,6 +67,7 @@ function reset () { total: 0, success: 0, error: 0, + external: 0, abandoned: 0 } } @@ -209,10 +210,10 @@ function getElemString (elem) { return ret } -// The user pressed play. It either worked or showed the -// 'Play in VLC' codec error +// The user pressed play. Did it work, display an error, +// open an external player or did user abandon the attempt? function logPlayAttempt (result) { - if (!['success', 'error', 'abandoned'].includes(result)) { + if (!['success', 'error', 'external', 'abandoned'].includes(result)) { return console.error('Unknown play attempt result', result) }