Log successful attempts to open an external player

This commit is contained in:
Adam Gotlib
2016-10-11 11:42:04 +02:00
committed by Dan Flettre
parent de2db211cc
commit d8904aaf6e
4 changed files with 14 additions and 8 deletions

View File

@@ -56,7 +56,10 @@ module.exports = class MediaController {
const state = this.state const state = this.state
state.playing.location = 'external' state.playing.location = 'external'
let open = function () { const onServerRunning = function () {
state.playing.isReady = true
telemetry.logPlayAttempt('external')
const mediaURL = Playlist.getCurrentLocalURL(state) const mediaURL = Playlist.getCurrentLocalURL(state)
ipcRenderer.send('openExternalPlayer', ipcRenderer.send('openExternalPlayer',
state.saved.prefs.externalPlayerPath, state.saved.prefs.externalPlayerPath,
@@ -64,8 +67,8 @@ module.exports = class MediaController {
state.window.title) state.window.title)
} }
if (state.server != null) open() if (state.server != null) onServerRunning()
else ipcRenderer.once('wt-server-running', open) else ipcRenderer.once('wt-server-running', onServerRunning)
} }
externalPlayerNotFound () { externalPlayerNotFound () {

View File

@@ -223,6 +223,8 @@ module.exports = class PlaybackController {
// Starts WebTorrent server for media streaming // Starts WebTorrent server for media streaming
startServer (torrentSummary) { startServer (torrentSummary) {
const state = this.state
if (torrentSummary.status === 'paused') { if (torrentSummary.status === 'paused') {
dispatch('startTorrentingSummary', torrentSummary.torrentKey) dispatch('startTorrentingSummary', torrentSummary.torrentKey)
ipcRenderer.once('wt-ready-' + torrentSummary.infoHash, ipcRenderer.once('wt-ready-' + torrentSummary.infoHash,
@@ -233,7 +235,7 @@ module.exports = class PlaybackController {
function onTorrentReady () { function onTorrentReady () {
ipcRenderer.send('wt-start-server', torrentSummary.infoHash) 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 })
} }
} }

View File

@@ -91,7 +91,7 @@ function getDefaultPlayState () {
location: 'local', /* 'local', 'chromecast', 'airplay' */ location: 'local', /* 'local', 'chromecast', 'airplay' */
type: null, /* 'audio' or 'video', could be 'other' if ever support eg streaming to VLC */ type: null, /* 'audio' or 'video', could be 'other' if ever support eg streaming to VLC */
currentTime: 0, /* seconds */ currentTime: 0, /* seconds */
duration: 1, /* seconds */, duration: 1, /* seconds */
isReady: false, isReady: false,
isPaused: true, isPaused: true,
isStalled: false, isStalled: false,

View File

@@ -67,6 +67,7 @@ function reset () {
total: 0, total: 0,
success: 0, success: 0,
error: 0, error: 0,
external: 0,
abandoned: 0 abandoned: 0
} }
} }
@@ -209,10 +210,10 @@ function getElemString (elem) {
return ret return ret
} }
// The user pressed play. It either worked or showed the // The user pressed play. Did it work, display an error,
// 'Play in VLC' codec error // open an external player or did user abandon the attempt?
function logPlayAttempt (result) { function logPlayAttempt (result) {
if (!['success', 'error', 'abandoned'].includes(result)) { if (!['success', 'error', 'external', 'abandoned'].includes(result)) {
return console.error('Unknown play attempt result', result) return console.error('Unknown play attempt result', result)
} }