added stream proerty to instance

This commit is contained in:
SrGooglo 2023-03-30 22:49:41 +00:00
parent 25100c347a
commit 62a54a0d2d

View File

@ -33,6 +33,7 @@ class AudioPlayerStorage {
} }
} }
// TODO: Check if source playing is a stream. Also handle if it's a stream resuming after a pause will seek to the last position
export default class Player extends Core { export default class Player extends Core {
static refName = "player" static refName = "player"
@ -287,6 +288,7 @@ export default class Player extends Core {
if (typeof manifest === "string") { if (typeof manifest === "string") {
manifest = { manifest = {
src: manifest, src: manifest,
stream: false,
} }
} }
@ -425,6 +427,13 @@ export default class Player extends Core {
createCrossfadeInterval() createCrossfadeInterval()
}) })
// detect if the audio is a live stream
instanceObj.audioElement.addEventListener("loadedmetadata", () => {
if (instanceObj.audioElement.duration === Infinity) {
instanceObj.manifest.stream = true
}
})
//await this.instanciateRealtimeAnalyzerNode() //await this.instanciateRealtimeAnalyzerNode()
instanceObj.track = this.audioContext.createMediaElementSource(instanceObj.audioElement) instanceObj.track = this.audioContext.createMediaElementSource(instanceObj.audioElement)