Remove play button spinner, go to player page immediately

This commit is contained in:
DC
2016-09-22 22:43:53 -07:00
parent 2788d7433b
commit 0dd1683298
3 changed files with 7 additions and 46 deletions

View File

@@ -4,8 +4,7 @@ const path = require('path')
const Cast = require('../lib/cast') const Cast = require('../lib/cast')
const {dispatch} = require('../lib/dispatcher') const {dispatch} = require('../lib/dispatcher')
const telemetry = require('../lib/telemetry') const telemetry = require('../lib/telemetry')
const {UnplayableFileError, UnplayableTorrentError, const {UnplayableFileError, UnplayableTorrentError} = require('../lib/errors')
PlaybackTimedOutError} = require('../lib/errors')
const sound = require('../lib/sound') const sound = require('../lib/sound')
const TorrentPlayer = require('../lib/torrent-player') const TorrentPlayer = require('../lib/torrent-player')
const TorrentSummary = require('../lib/torrent-summary') const TorrentSummary = require('../lib/torrent-summary')
@@ -223,34 +222,11 @@ module.exports = class PlaybackController {
state.playing.infoHash = torrentSummary.infoHash state.playing.infoHash = torrentSummary.infoHash
// update UI to show pending playback // update UI to show pending playback
if (torrentSummary.progress !== 1) sound.play('PLAY') sound.play('PLAY')
// TODO: remove torrentSummary.playStatus
torrentSummary.playStatus = 'requested'
this.update()
const timeout = setTimeout(() => { this.startServer(torrentSummary)
telemetry.logPlayAttempt('timeout') ipcRenderer.send('onPlayerOpen')
// TODO: remove torrentSummary.playStatus this.updatePlayer(infoHash, index, true, cb)
torrentSummary.playStatus = 'timeout' /* no seeders available? */
sound.play('ERROR')
cb(new PlaybackTimedOutError())
this.update()
}, 10000) /* give it a few seconds */
this.startServer(torrentSummary, () => {
clearTimeout(timeout)
// if we timed out (user clicked play a long time ago), don't autoplay
const timedOut = torrentSummary.playStatus === 'timeout'
delete torrentSummary.playStatus
if (timedOut) {
ipcRenderer.send('wt-stop-server')
return this.update()
}
ipcRenderer.send('onPlayerOpen')
this.updatePlayer(infoHash, index, true, cb)
})
} }
// Starts WebTorrent server for media streaming // Starts WebTorrent server for media streaming
@@ -265,7 +241,6 @@ 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-' + torrentSummary.infoHash, () => cb())
} }
} }

View File

@@ -215,9 +215,6 @@ function saveImmediate (state, cb) {
if (key === 'progress' || key === 'torrentKey') { if (key === 'progress' || key === 'torrentKey') {
continue // Don't save progress info or key for the webtorrent process continue // Don't save progress info or key for the webtorrent process
} }
if (key === 'playStatus') {
continue // Don't save whether a torrent is playing / pending
}
if (key === 'error') { if (key === 'error') {
continue // Don't save error states continue // Don't save error states
} }

View File

@@ -56,8 +56,6 @@ module.exports = class TorrentList extends React.Component {
// Foreground: name of the torrent, basic info like size, play button, // Foreground: name of the torrent, basic info like size, play button,
// cast buttons if available, and delete // cast buttons if available, and delete
const classes = ['torrent'] const classes = ['torrent']
// playStatus turns the play button into a loading spinner or error icon
if (torrentSummary.playStatus) classes.push(torrentSummary.playStatus)
if (isSelected) classes.push('selected') if (isSelected) classes.push('selected')
if (!infoHash) classes.push('disabled') if (!infoHash) classes.push('disabled')
if (!torrentSummary.torrentKey) throw new InvalidTorrentError('Missing torrentKey') if (!torrentSummary.torrentKey) throw new InvalidTorrentError('Missing torrentKey')
@@ -197,25 +195,16 @@ module.exports = class TorrentList extends React.Component {
renderTorrentButtons (torrentSummary) { renderTorrentButtons (torrentSummary) {
const infoHash = torrentSummary.infoHash const infoHash = torrentSummary.infoHash
let playIcon, playTooltip
if (torrentSummary.playStatus === 'timeout') {
playIcon = 'warning'
playTooltip = 'Playback timed out. No seeds? No internet? Click to try again.'
} else {
playIcon = 'play_circle_outline'
playTooltip = 'Start streaming'
}
// Only show the play/dowload buttons for torrents that contain playable media // Only show the play/dowload buttons for torrents that contain playable media
let playButton let playButton
if (!torrentSummary.error && TorrentPlayer.isPlayableTorrentSummary(torrentSummary)) { if (!torrentSummary.error && TorrentPlayer.isPlayableTorrentSummary(torrentSummary)) {
playButton = ( playButton = (
<i <i
key='play-button' key='play-button'
title={playTooltip} title='Start streaming'
className={'icon play'} className={'icon play'}
onClick={dispatcher('playFile', infoHash)}> onClick={dispatcher('playFile', infoHash)}>
{playIcon} play_circle_outline
</i> </i>
) )
} }