mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-30 18:48:55 +01:00
Merge pull request #1205 from lkiesow/api-start-end-date
Allow specifying start and end of progress via API
This commit is contained in:
commit
34ff7efa27
@ -63,12 +63,12 @@ class MediaProgress {
|
|||||||
this.isFinished = !!progress.isFinished || this.progress == 1
|
this.isFinished = !!progress.isFinished || this.progress == 1
|
||||||
this.hideFromContinueListening = !!progress.hideFromContinueListening
|
this.hideFromContinueListening = !!progress.hideFromContinueListening
|
||||||
this.lastUpdate = Date.now()
|
this.lastUpdate = Date.now()
|
||||||
this.startedAt = Date.now()
|
|
||||||
this.finishedAt = null
|
this.finishedAt = null
|
||||||
if (this.isFinished) {
|
if (this.isFinished) {
|
||||||
this.finishedAt = Date.now()
|
this.finishedAt = progress.finishedAt || Date.now()
|
||||||
this.progress = 1
|
this.progress = 1
|
||||||
}
|
}
|
||||||
|
this.startedAt = this.finishedAt || Date.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
update(payload) {
|
update(payload) {
|
||||||
@ -95,7 +95,7 @@ class MediaProgress {
|
|||||||
// If time remaining is less than 5 seconds then mark as finished
|
// If time remaining is less than 5 seconds then mark as finished
|
||||||
if ((this.progress >= 1 || (this.duration && !isNaN(timeRemaining) && timeRemaining < 5))) {
|
if ((this.progress >= 1 || (this.duration && !isNaN(timeRemaining) && timeRemaining < 5))) {
|
||||||
this.isFinished = true
|
this.isFinished = true
|
||||||
this.finishedAt = Date.now()
|
this.finishedAt = payload.finishedAt || Date.now()
|
||||||
this.progress = 1
|
this.progress = 1
|
||||||
} else if (this.progress < 1 && this.isFinished) {
|
} else if (this.progress < 1 && this.isFinished) {
|
||||||
this.isFinished = false
|
this.isFinished = false
|
||||||
@ -103,7 +103,7 @@ class MediaProgress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.startedAt) {
|
if (!this.startedAt) {
|
||||||
this.startedAt = Date.now()
|
this.startedAt = this.finishedAt || Date.now()
|
||||||
}
|
}
|
||||||
if (hasUpdates) {
|
if (hasUpdates) {
|
||||||
if (payload.hideFromContinueListening === undefined) {
|
if (payload.hideFromContinueListening === undefined) {
|
||||||
|
Loading…
Reference in New Issue
Block a user