From 62a54a0d2df8ba5f1ccaa73a641f357fc1c4f265 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Thu, 30 Mar 2023 22:49:41 +0000 Subject: [PATCH] added `stream` proerty to instance --- packages/app/src/cores/player/index.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/app/src/cores/player/index.jsx b/packages/app/src/cores/player/index.jsx index 499e2a22..f1d49526 100755 --- a/packages/app/src/cores/player/index.jsx +++ b/packages/app/src/cores/player/index.jsx @@ -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 { static refName = "player" @@ -287,6 +288,7 @@ export default class Player extends Core { if (typeof manifest === "string") { manifest = { src: manifest, + stream: false, } } @@ -425,6 +427,13 @@ export default class Player extends Core { 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() instanceObj.track = this.audioContext.createMediaElementSource(instanceObj.audioElement)