Restore playback state when reopening player (#877)
This commit is contained in:
@@ -34,12 +34,20 @@ module.exports = class PlaybackController {
|
|||||||
else this.play()
|
else this.play()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
let initialized = false
|
||||||
state.location.go({
|
state.location.go({
|
||||||
url: 'player',
|
url: 'player',
|
||||||
setup: (cb) => {
|
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) => {
|
this.openPlayer(infoHash, index, (err) => {
|
||||||
if (!err) this.play
|
if (!err) this.play()
|
||||||
cb(err)
|
cb(err)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -211,10 +219,6 @@ module.exports = class PlaybackController {
|
|||||||
const state = this.state
|
const state = this.state
|
||||||
const torrentSummary = TorrentSummary.getByKey(state, infoHash)
|
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
|
state.playing.infoHash = torrentSummary.infoHash
|
||||||
|
|
||||||
// update UI to show pending playback
|
// update UI to show pending playback
|
||||||
|
|||||||
Reference in New Issue
Block a user