2022-02-23 00:33:55 +01:00
|
|
|
export default class AudioTrack {
|
2022-03-18 01:10:47 +01:00
|
|
|
constructor(track, userToken) {
|
2022-02-23 00:33:55 +01:00
|
|
|
this.index = track.index || 0
|
|
|
|
this.startOffset = track.startOffset || 0 // Total time of all previous tracks
|
|
|
|
this.duration = track.duration || 0
|
2022-03-18 01:10:47 +01:00
|
|
|
this.title = track.title || ''
|
2022-02-23 00:33:55 +01:00
|
|
|
this.contentUrl = track.contentUrl || null
|
|
|
|
this.mimeType = track.mimeType
|
2022-03-18 01:10:47 +01:00
|
|
|
|
|
|
|
this.userToken = userToken
|
2022-02-23 00:33:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
get fullContentUrl() {
|
|
|
|
if (!this.contentUrl || this.contentUrl.startsWith('http')) return this.contentUrl
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
2022-03-18 01:10:47 +01:00
|
|
|
return `${process.env.serverUrl}${this.contentUrl}?token=${this.userToken}`
|
2022-02-23 00:33:55 +01:00
|
|
|
}
|
2022-03-18 01:10:47 +01:00
|
|
|
return `${window.location.origin}${this.contentUrl}?token=${this.userToken}`
|
2022-02-23 00:33:55 +01:00
|
|
|
}
|
2022-03-05 01:44:20 +01:00
|
|
|
|
|
|
|
get relativeContentUrl() {
|
|
|
|
if (!this.contentUrl || this.contentUrl.startsWith('http')) return this.contentUrl
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
2022-03-18 01:10:47 +01:00
|
|
|
return `${process.env.serverUrl}${this.contentUrl}?token=${this.userToken}`
|
2022-03-05 01:44:20 +01:00
|
|
|
}
|
|
|
|
|
2022-03-18 21:31:46 +01:00
|
|
|
return this.contentUrl + `?token=${this.userToken}`
|
2022-03-05 01:44:20 +01:00
|
|
|
}
|
2022-02-23 00:33:55 +01:00
|
|
|
}
|