mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-01 00:18:14 +01:00
add new setDuration and use that
This commit is contained in:
parent
0c24a1e626
commit
d430d9f3ed
@ -164,7 +164,7 @@ class PlaybackSessionManager {
|
|||||||
// New session from local
|
// New session from local
|
||||||
session = new PlaybackSession(sessionJson)
|
session = new PlaybackSession(sessionJson)
|
||||||
session.deviceInfo = deviceInfo
|
session.deviceInfo = deviceInfo
|
||||||
session.duration = libraryItem.media.duration
|
session.setDuration(libraryItem, sessionJson.episodeId)
|
||||||
Logger.debug(`[PlaybackSessionManager] Inserting new session for "${session.displayTitle}" (${session.id})`)
|
Logger.debug(`[PlaybackSessionManager] Inserting new session for "${session.displayTitle}" (${session.id})`)
|
||||||
await Database.createPlaybackSession(session)
|
await Database.createPlaybackSession(session)
|
||||||
} else {
|
} else {
|
||||||
|
@ -219,11 +219,7 @@ class PlaybackSession {
|
|||||||
this.displayAuthor = libraryItem.media.getPlaybackAuthor()
|
this.displayAuthor = libraryItem.media.getPlaybackAuthor()
|
||||||
this.coverPath = libraryItem.media.coverPath
|
this.coverPath = libraryItem.media.coverPath
|
||||||
|
|
||||||
if (episodeId) {
|
this.setDuration(libraryItem, episodeId)
|
||||||
this.duration = libraryItem.media.getEpisodeDuration(episodeId)
|
|
||||||
} else {
|
|
||||||
this.duration = libraryItem.media.duration
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mediaPlayer = mediaPlayer
|
this.mediaPlayer = mediaPlayer
|
||||||
this.deviceInfo = deviceInfo || new DeviceInfo()
|
this.deviceInfo = deviceInfo || new DeviceInfo()
|
||||||
@ -239,6 +235,14 @@ class PlaybackSession {
|
|||||||
this.updatedAt = Date.now()
|
this.updatedAt = Date.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDuration(libraryItem, episodeId) {
|
||||||
|
if (episodeId) {
|
||||||
|
this.duration = libraryItem.media.getEpisodeDuration(episodeId)
|
||||||
|
} else {
|
||||||
|
this.duration = libraryItem.media.duration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addListeningTime(timeListened) {
|
addListeningTime(timeListened) {
|
||||||
if (!timeListened || isNaN(timeListened)) return
|
if (!timeListened || isNaN(timeListened)) return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user