Add displayTitle and displayAuthor to playback session

This commit is contained in:
advplyr 2022-04-02 10:26:42 -05:00
parent 9ae71615bc
commit 3d3f20296c
5 changed files with 37 additions and 7 deletions

View File

@ -67,7 +67,8 @@ export default {
sleepTimerSet: false, sleepTimerSet: false,
sleepTimerTime: 0, sleepTimerTime: 0,
sleepTimerRemaining: 0, sleepTimerRemaining: 0,
sleepTimer: null sleepTimer: null,
displayTitle: null
} }
}, },
computed: { computed: {
@ -117,9 +118,6 @@ export default {
isPodcast() { isPodcast() {
return this.streamLibraryItem ? this.streamLibraryItem.mediaType === 'podcast' : false return this.streamLibraryItem ? this.streamLibraryItem.mediaType === 'podcast' : false
}, },
episode() {
return this.playerHandler.episode
},
mediaMetadata() { mediaMetadata() {
return this.media.metadata || {} return this.media.metadata || {}
}, },
@ -127,7 +125,7 @@ export default {
return this.media.chapters || [] return this.media.chapters || []
}, },
title() { title() {
if (this.episode) return this.episode.title if (this.playerHandler.displayTitle) return this.playerHandler.displayTitle
return this.mediaMetadata.title || 'No Title' return this.mediaMetadata.title || 'No Title'
}, },
authors() { authors() {

View File

@ -7,6 +7,8 @@ export default class PlayerHandler {
this.ctx = ctx this.ctx = ctx
this.libraryItem = null this.libraryItem = null
this.episodeId = null this.episodeId = null
this.displayTitle = null
this.displayAuthor = null
this.playWhenReady = false this.playWhenReady = false
this.player = null this.player = null
this.playerState = 'IDLE' this.playerState = 'IDLE'
@ -160,6 +162,8 @@ export default class PlayerHandler {
prepareSession(session) { prepareSession(session) {
this.startTime = session.currentTime this.startTime = session.currentTime
this.currentSessionId = session.id this.currentSessionId = session.id
this.displayTitle = session.displayTitle
this.displayAuthor = session.displayAuthor
console.log('[PlayerHandler] Preparing Session', session) console.log('[PlayerHandler] Preparing Session', session)
var audioTracks = session.audioTracks.map(at => new AudioTrack(at, this.userToken)) var audioTracks = session.audioTracks.map(at => new AudioTrack(at, this.userToken))

View File

@ -13,6 +13,8 @@ class PlaybackSession {
this.mediaType = null this.mediaType = null
this.mediaMetadata = null this.mediaMetadata = null
this.displayTitle = null
this.displayAuthor = null
this.coverPath = null this.coverPath = null
this.duration = null this.duration = null
@ -45,6 +47,8 @@ class PlaybackSession {
episodeId: this.episodeId, episodeId: this.episodeId,
mediaType: this.mediaType, mediaType: this.mediaType,
mediaMetadata: this.mediaMetadata ? this.mediaMetadata.toJSON() : null, mediaMetadata: this.mediaMetadata ? this.mediaMetadata.toJSON() : null,
displayTitle: this.displayTitle,
displayAuthor: this.displayAuthor,
coverPath: this.coverPath, coverPath: this.coverPath,
duration: this.duration, duration: this.duration,
playMethod: this.playMethod, playMethod: this.playMethod,
@ -65,6 +69,8 @@ class PlaybackSession {
episodeId: this.episodeId, episodeId: this.episodeId,
mediaType: this.mediaType, mediaType: this.mediaType,
mediaMetadata: this.mediaMetadata ? this.mediaMetadata.toJSON() : null, mediaMetadata: this.mediaMetadata ? this.mediaMetadata.toJSON() : null,
displayTitle: this.displayTitle,
displayAuthor: this.displayAuthor,
coverPath: this.coverPath, coverPath: this.coverPath,
duration: this.duration, duration: this.duration,
playMethod: this.playMethod, playMethod: this.playMethod,
@ -84,7 +90,7 @@ class PlaybackSession {
this.sessionType = session.sessionType this.sessionType = session.sessionType
this.userId = session.userId this.userId = session.userId
this.libraryItemId = session.libraryItemId this.libraryItemId = session.libraryItemId
this.episodeId = session.episodeId, this.episodeId = session.episodeId
this.mediaType = session.mediaType this.mediaType = session.mediaType
this.duration = session.duration this.duration = session.duration
this.playMethod = session.playMethod this.playMethod = session.playMethod
@ -97,6 +103,8 @@ class PlaybackSession {
this.mediaMetadata = new PodcastMetadata(session.mediaMetadata) this.mediaMetadata = new PodcastMetadata(session.mediaMetadata)
} }
} }
this.displayTitle = session.displayTitle || ''
this.displayAuthor = session.displayAuthor || ''
this.coverPath = session.coverPath this.coverPath = session.coverPath
this.date = session.date this.date = session.date
this.dayOfWeek = session.dayOfWeek this.dayOfWeek = session.dayOfWeek
@ -118,6 +126,8 @@ class PlaybackSession {
this.episodeId = episodeId this.episodeId = episodeId
this.mediaType = libraryItem.mediaType this.mediaType = libraryItem.mediaType
this.mediaMetadata = libraryItem.media.metadata.clone() this.mediaMetadata = libraryItem.media.metadata.clone()
this.displayTitle = libraryItem.media.getPlaybackTitle(episodeId)
this.displayAuthor = libraryItem.media.getPlaybackAuthor(episodeId)
this.coverPath = libraryItem.media.coverPath this.coverPath = libraryItem.media.coverPath
this.duration = libraryItem.media.duration this.duration = libraryItem.media.duration

View File

@ -408,5 +408,13 @@ class Book {
return tracklist return tracklist
} }
getPlaybackTitle() {
return this.metadata.title
}
getPlaybackAuthor() {
return this.metadata.authorName
}
} }
module.exports = Book module.exports = Book

View File

@ -213,5 +213,15 @@ class Podcast {
removeEpisode(episodeId) { removeEpisode(episodeId) {
this.episodes = this.episodes.filter(ep => ep.id !== episodeId) this.episodes = this.episodes.filter(ep => ep.id !== episodeId)
} }
getPlaybackTitle(episodeId) {
var episode = this.episodes.find(ep => ep.id == episodeId)
if (!episode) return this.metadata.title
return episode.title
}
getPlaybackAuthor() {
return this.metadata.author
}
} }
module.exports = Podcast module.exports = Podcast