add new setDuration and use that

This commit is contained in:
Lauri Vuorela 2024-09-12 20:05:08 +02:00
parent 0c24a1e626
commit d430d9f3ed
2 changed files with 10 additions and 6 deletions

View file

@ -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()
@ -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