mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-10 13:59:40 +00:00
New data model play media entity, PlaybackSessionManager
This commit is contained in:
parent
1cf9e85272
commit
099ae7c776
54 changed files with 841 additions and 902 deletions
42
server/objects/files/AudioTrack.js
Normal file
42
server/objects/files/AudioTrack.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
const Path = require('path')
|
||||
|
||||
class AudioTrack {
|
||||
constructor() {
|
||||
this.index = null
|
||||
this.startOffset = null
|
||||
this.duration = null
|
||||
this.title = null
|
||||
this.contentUrl = null
|
||||
this.mimeType = null
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
index: this.index,
|
||||
startOffset: this.startOffset,
|
||||
duration: this.duration,
|
||||
title: this.title,
|
||||
contentUrl: this.contentUrl,
|
||||
mimeType: this.mimeType
|
||||
}
|
||||
}
|
||||
|
||||
setData(itemId, audioFile, startOffset) {
|
||||
this.index = audioFile.index
|
||||
this.startOffset = startOffset
|
||||
this.duration = audioFile.duration
|
||||
this.title = audioFile.metadata.filename || ''
|
||||
this.contentUrl = Path.join(`/s/item/${itemId}`, audioFile.metadata.relPath)
|
||||
this.mimeType = audioFile.mimeType
|
||||
}
|
||||
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue