mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-19 00:18:56 +01:00
Merge pull request #3411 from justcallmelarry/feature/add-duration-when-creating-sessions
Add duration to local sessions on creation
This commit is contained in:
commit
3d9af89e24
@ -164,6 +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.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