Skip to content

Commit

Permalink
Restore playback state when reopening player (#877)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldob authored and dcposch committed Sep 3, 2016
1 parent 704455c commit 11f8e42
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/renderer/controllers/playback-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
},
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 11f8e42

Please sign in to comment.