Save video position
This commit is contained in:
@@ -1025,6 +1025,15 @@ function openPlayerFromActiveTorrent (torrentSummary, index, timeout, cb) {
|
|||||||
: TorrentPlayer.isAudio(fileSummary) ? 'audio'
|
: TorrentPlayer.isAudio(fileSummary) ? 'audio'
|
||||||
: 'other'
|
: 'other'
|
||||||
|
|
||||||
|
// pick up where we left off
|
||||||
|
if (fileSummary.currentTime) {
|
||||||
|
var fraction = fileSummary.currentTime / fileSummary.duration
|
||||||
|
var secondsLeft = fileSummary.duration - fileSummary.currentTime
|
||||||
|
if (fraction < 0.9 && secondsLeft > 10) {
|
||||||
|
state.playing.jumpToTime = fileSummary.currentTime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if it's audio, parse out the metadata (artist, title, etc)
|
// if it's audio, parse out the metadata (artist, title, etc)
|
||||||
if (state.playing.type === 'audio' && !fileSummary.audioInfo) {
|
if (state.playing.type === 'audio' && !fileSummary.audioInfo) {
|
||||||
ipcRenderer.send('wt-get-audio-metadata', torrentSummary.infoHash, index)
|
ipcRenderer.send('wt-get-audio-metadata', torrentSummary.infoHash, index)
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ var LocationHistory = require('./lib/location-history')
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
getInitialState,
|
getInitialState,
|
||||||
getDefaultPlayState,
|
getDefaultPlayState,
|
||||||
getDefaultSavedState,
|
getDefaultSavedState
|
||||||
getPlayingTorrentSummary
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInitialState () {
|
function getInitialState () {
|
||||||
@@ -63,7 +62,8 @@ function getInitialState () {
|
|||||||
/*
|
/*
|
||||||
* Getters, for convenience
|
* Getters, for convenience
|
||||||
*/
|
*/
|
||||||
getPlayingTorrentSummary
|
getPlayingTorrentSummary,
|
||||||
|
getPlayingFileSummary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,3 +276,9 @@ function getPlayingTorrentSummary () {
|
|||||||
var infoHash = this.playing.infoHash
|
var infoHash = this.playing.infoHash
|
||||||
return this.saved.torrents.find((x) => x.infoHash === infoHash)
|
return this.saved.torrents.find((x) => x.infoHash === infoHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPlayingFileSummary () {
|
||||||
|
var torrentSummary = this.getPlayingTorrentSummary()
|
||||||
|
if (!torrentSummary) return null
|
||||||
|
return torrentSummary.files[this.playing.fileIndex]
|
||||||
|
}
|
||||||
|
|||||||
@@ -63,8 +63,10 @@ function renderMedia (state) {
|
|||||||
tracks[j].mode = (j === state.playing.subtitles.selectedIndex) ? 'showing' : 'hidden'
|
tracks[j].mode = (j === state.playing.subtitles.selectedIndex) ? 'showing' : 'hidden'
|
||||||
}
|
}
|
||||||
|
|
||||||
state.playing.currentTime = mediaElement.currentTime
|
// Save video position
|
||||||
state.playing.duration = mediaElement.duration
|
var file = state.getPlayingFileSummary()
|
||||||
|
file.currentTime = state.playing.currentTime = mediaElement.currentTime
|
||||||
|
file.duration = state.playing.duration = mediaElement.duration
|
||||||
state.playing.volume = mediaElement.volume
|
state.playing.volume = mediaElement.volume
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,8 +172,7 @@ function renderOverlay (state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderAudioMetadata (state) {
|
function renderAudioMetadata (state) {
|
||||||
var torrentSummary = state.getPlayingTorrentSummary()
|
var fileSummary = state.getPlayingFileSummary()
|
||||||
var fileSummary = torrentSummary.files[state.playing.fileIndex]
|
|
||||||
if (!fileSummary.audioInfo) return
|
if (!fileSummary.audioInfo) return
|
||||||
var info = fileSummary.audioInfo
|
var info = fileSummary.audioInfo
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user