Add new api endpoint for direct playing audio files using session id #4259

This commit is contained in:
advplyr 2025-05-05 17:00:43 -05:00
parent 45987ffd63
commit 336de49d8d
5 changed files with 62 additions and 13 deletions

View file

@ -1,5 +1,5 @@
export default class AudioTrack {
constructor(track, userToken, routerBasePath) {
constructor(track, sessionId, routerBasePath) {
this.index = track.index || 0
this.startOffset = track.startOffset || 0 // Total time of all previous tracks
this.duration = track.duration || 0
@ -8,28 +8,25 @@ export default class AudioTrack {
this.mimeType = track.mimeType
this.metadata = track.metadata || {}
this.userToken = userToken
this.sessionId = sessionId
this.routerBasePath = routerBasePath || ''
this.sessionTrackUrl = `/public/session/${sessionId}/track/${this.index}`
}
/**
* Used for CastPlayer
*/
get fullContentUrl() {
if (!this.contentUrl || this.contentUrl.startsWith('http')) return this.contentUrl
if (process.env.NODE_ENV === 'development') {
return `${process.env.serverUrl}${this.contentUrl}?token=${this.userToken}`
return `${process.env.serverUrl}${this.sessionTrackUrl}`
}
return `${window.location.origin}${this.routerBasePath}${this.contentUrl}?token=${this.userToken}`
return `${window.location.origin}${this.routerBasePath}${this.sessionTrackUrl}`
}
/**
* Used for LocalPlayer
*/
get relativeContentUrl() {
if (!this.contentUrl || this.contentUrl.startsWith('http')) return this.contentUrl
return `${this.routerBasePath}${this.contentUrl}?token=${this.userToken}`
return `${this.routerBasePath}${this.sessionTrackUrl}`
}
}