Restore playback state when reopening player (#877)

This commit is contained in:
Adam Gotlib
2016-09-04 00:25:19 +02:00
committed by DC
parent 704455c432
commit 11f8e428a0

View File

@@ -34,12 +34,20 @@ module.exports = class PlaybackController {
else this.play()
})
} else {
let initialized = false
state.location.go({
url: 'player',
setup: (cb) => {
this.play()
const torrentSummary = TorrentSummary.getByKey(state, infoHash)
if (index === undefined || initialized) index = torrentSummary.mostRecentFileIndex
if (index === undefined) index = torrentSummary.files.findIndex(TorrentPlayer.isPlayable)
if (index === undefined) return cb(new errors.UnplayableError())
initialized = true
this.openPlayer(infoHash, index, (err) => {
if (!err) this.play
if (!err) this.play()
cb(err)
})
},
@@ -211,10 +219,6 @@ module.exports = class PlaybackController {
const state = this.state
const torrentSummary = TorrentSummary.getByKey(state, infoHash)
if (index === undefined) index = torrentSummary.mostRecentFileIndex
if (index === undefined) index = torrentSummary.files.findIndex(TorrentPlayer.isPlayable)
if (index === undefined) return cb(new errors.UnplayableError())
state.playing.infoHash = torrentSummary.infoHash
// update UI to show pending playback