New data model play media entity, PlaybackSessionManager

This commit is contained in:
advplyr 2022-03-17 19:10:47 -05:00
parent 1cf9e85272
commit 099ae7c776
54 changed files with 841 additions and 902 deletions

View file

@ -64,7 +64,8 @@ class AudioFile {
channelLayout: this.channelLayout,
chapters: this.chapters,
embeddedCoverArt: this.embeddedCoverArt,
metaTags: this.metaTags ? this.metaTags.toJSON() : {}
metaTags: this.metaTags ? this.metaTags.toJSON() : {},
mimeType: this.mimeType
}
}
@ -72,9 +73,6 @@ class AudioFile {
this.index = data.index
this.ino = data.ino
this.metadata = new FileMetadata(data.metadata || {})
if (!this.metadata.toJSON) {
console.error('No metadata tojosnm\n\n\n\n\n\n', this)
}
this.addedAt = data.addedAt
this.updatedAt = data.updatedAt
this.manuallyVerified = !!data.manuallyVerified
@ -103,6 +101,22 @@ class AudioFile {
this.metaTags = new AudioMetaTags(data.metaTags || {})
}
get mimeType() {
var ext = this.metadata.ext
if (ext === '.mp3' || ext === '.m4b' || ext === '.m4a') {
return 'audio/mpeg'
} else if (ext === '.mp4') {
return 'audio/mp4'
} else if (ext === '.ogg') {
return 'audio/ogg'
} else if (ext === '.aac' || ext === '.m4p') {
return 'audio/aac'
} else if (ext === '.flac') {
return 'audio/flac'
}
return 'audio/mpeg'
}
// New scanner creates AudioFile from AudioFileScanner
setDataFromProbe(libraryFile, probeData) {
this.ino = libraryFile.ino || null

View 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