aboutsummaryrefslogtreecommitdiff
path: root/web/script/player/player.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/script/player/player.ts')
-rw-r--r--web/script/player/player.ts6
1 files changed, 5 insertions, 1 deletions
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<PlayerTrack[]>([]);
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]))