From 1f11c16aefe71d68605d2cd0ad5da9c016aa3570 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 2 Oct 2023 22:58:44 +0200 Subject: testing profile autoselect --- web/script/player/player.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'web/script/player/player.ts') diff --git a/web/script/player/player.ts b/web/script/player/player.ts index 08975b2..f3a1f6e 100644 --- a/web/script/player/player.ts +++ b/web/script/player/player.ts @@ -2,6 +2,7 @@ import { OVar, e } from "../jshelper/mod.ts"; import { JhlsMetadata, TimeRange } from "./jhls.d.ts"; import { SegmentDownloader } from "./download.ts"; import { PlayerTrack } from "./track.ts"; +import { ProfileSelector } from "./profiles.ts"; export interface BufferRange extends TimeRange { status: "buffered" | "loading" | "queued" } export class Player { @@ -9,6 +10,7 @@ export class Player { public media_source = new MediaSource(); public tracks = new OVar([]); public downloader: SegmentDownloader = new SegmentDownloader(); + public profile_selector!: ProfileSelector public position = new OVar(0) public duration = new OVar(1) @@ -63,10 +65,12 @@ export class Player { const res = await fetch(`/n/${encodeURIComponent(this.node_id)}/stream?format=jhls`) if (!res.ok) return this.error.value = "Cannot download JHLS metadata" const metadata = await res.json() as JhlsMetadata - this.buffering_status.value = undefined + this.buffering_status.value = undefined this.duration.value = metadata.duration this.video.src = URL.createObjectURL(this.media_source) + this.profile_selector = new ProfileSelector(this.downloader.bandwidth, metadata) + this.media_source.addEventListener("sourceopen", async () => { this.tracks.value.push(new PlayerTrack(this, this.node_id, 0, metadata.tracks[0])) this.tracks.value.push(new PlayerTrack(this, this.node_id, 1, metadata.tracks[1])) -- cgit v1.3