Skip to content

Commit

Permalink
add new setDuration and use that
Browse files Browse the repository at this point in the history
  • Loading branch information
justcallmelarry committed Sep 12, 2024
1 parent 0c24a1e commit d430d9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/managers/PlaybackSessionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class PlaybackSessionManager {
// New session from local
session = new PlaybackSession(sessionJson)
session.deviceInfo = deviceInfo
session.duration = libraryItem.media.duration
session.setDuration(libraryItem, sessionJson.episodeId)
Logger.debug(`[PlaybackSessionManager] Inserting new session for "${session.displayTitle}" (${session.id})`)
await Database.createPlaybackSession(session)
} else {
Expand Down
14 changes: 9 additions & 5 deletions server/objects/PlaybackSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,7 @@ class PlaybackSession {
this.displayAuthor = libraryItem.media.getPlaybackAuthor()
this.coverPath = libraryItem.media.coverPath

if (episodeId) {
this.duration = libraryItem.media.getEpisodeDuration(episodeId)
} else {
this.duration = libraryItem.media.duration
}
this.setDuration(libraryItem, episodeId)

this.mediaPlayer = mediaPlayer
this.deviceInfo = deviceInfo || new DeviceInfo()
Expand All @@ -239,6 +235,14 @@ class PlaybackSession {
this.updatedAt = Date.now()
}

setDuration(libraryItem, episodeId) {
if (episodeId) {
this.duration = libraryItem.media.getEpisodeDuration(episodeId)
} else {
this.duration = libraryItem.media.duration
}
}

addListeningTime(timeListened) {
if (!timeListened || isNaN(timeListened)) return

Expand Down

0 comments on commit d430d9f

Please sign in to comment.