2022-03-18 01:10:47 +01:00
|
|
|
class AudioTrack {
|
|
|
|
constructor() {
|
|
|
|
this.index = null
|
|
|
|
this.startOffset = null
|
|
|
|
this.duration = null
|
|
|
|
this.title = null
|
|
|
|
this.contentUrl = null
|
|
|
|
this.mimeType = null
|
2023-01-07 22:58:57 +01:00
|
|
|
this.codec = null
|
2022-04-03 23:01:59 +02:00
|
|
|
this.metadata = null
|
2022-03-18 01:10:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
toJSON() {
|
|
|
|
return {
|
|
|
|
index: this.index,
|
|
|
|
startOffset: this.startOffset,
|
|
|
|
duration: this.duration,
|
|
|
|
title: this.title,
|
|
|
|
contentUrl: this.contentUrl,
|
2022-04-03 23:01:59 +02:00
|
|
|
mimeType: this.mimeType,
|
2023-01-07 22:58:57 +01:00
|
|
|
codec: this.codec,
|
2023-06-27 22:56:33 +02:00
|
|
|
metadata: this.metadata?.toJSON() || null
|
2022-03-18 01:10:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setData(itemId, audioFile, startOffset) {
|
|
|
|
this.index = audioFile.index
|
|
|
|
this.startOffset = startOffset
|
|
|
|
this.duration = audioFile.duration
|
|
|
|
this.title = audioFile.metadata.filename || ''
|
2023-06-27 22:56:33 +02:00
|
|
|
|
|
|
|
this.contentUrl = `${global.RouterBasePath}/api/items/${itemId}/file/${audioFile.ino}`
|
2022-03-18 01:10:47 +01:00
|
|
|
this.mimeType = audioFile.mimeType
|
2023-01-07 22:58:57 +01:00
|
|
|
this.codec = audioFile.codec || null
|
2022-04-03 23:01:59 +02:00
|
|
|
this.metadata = audioFile.metadata.clone()
|
2022-03-18 01:10:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setFromStream(title, duration, contentUrl) {
|
|
|
|
this.index = 1
|
|
|
|
this.startOffset = 0
|
|
|
|
this.duration = duration
|
|
|
|
this.title = title
|
|
|
|
this.contentUrl = contentUrl
|
|
|
|
this.mimeType = 'application/vnd.apple.mpegurl'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = AudioTrack
|