aboutsummaryrefslogtreecommitdiff
path: root/web/script/player/player.ts
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-10-02 22:58:44 +0200
committermetamuffin <metamuffin@disroot.org>2023-10-02 22:58:44 +0200
commit1f11c16aefe71d68605d2cd0ad5da9c016aa3570 (patch)
tree39a5cdc211c6f5da660acb4a8da36e88f88863c7 /web/script/player/player.ts
parente52890060edb988cf16f184d5711e539b1c1dd01 (diff)
downloadjellything-1f11c16aefe71d68605d2cd0ad5da9c016aa3570.tar
jellything-1f11c16aefe71d68605d2cd0ad5da9c016aa3570.tar.bz2
jellything-1f11c16aefe71d68605d2cd0ad5da9c016aa3570.tar.zst
testing profile autoselect
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]))