aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/script/player/player.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/web/script/player/player.ts b/web/script/player/player.ts
index 9151a2a..c87ae8f 100644
--- a/web/script/player/player.ts
+++ b/web/script/player/player.ts
@@ -76,9 +76,12 @@ export class Player {
async fetch_meta() {
this.set_pers("Loading media manifest...")
- const res = await fetch(`/n/${encodeURIComponent(this.node_id)}/stream?format=jhls`)
+ const res = await fetch(`/n/${encodeURIComponent(this.node_id)}/stream?format=jhls`, { headers: { "Accept": "application/json" } })
if (!res.ok) return this.error.value = "Cannot download JHLS metadata"
- const metadata = await res.json() as JhlsMetadata
+ let metadata!: JhlsMetadata & { error: string }
+ try { metadata = await res.json() }
+ catch (_) { this.set_pers("Error: Failed to fetch stream info") }
+ if (metadata.error) return this.set_pers("server error: " + metadata.error)
this.set_pers()
this.tracks = metadata.tracks