diff options
author | metamuffin <metamuffin@disroot.org> | 2023-10-02 21:35:31 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-10-02 21:35:31 +0200 |
commit | 7450134996a94c4629f1e112e90ad458a84c0c04 (patch) | |
tree | 0d5e80cc66ccb7da53bf936e2cc063b90a219a1d /web/script/player/player.ts | |
parent | f783143b4adf22be662db1af2ca00b34a868cf72 (diff) | |
download | jellything-7450134996a94c4629f1e112e90ad458a84c0c04.tar jellything-7450134996a94c4629f1e112e90ad458a84c0c04.tar.bz2 jellything-7450134996a94c4629f1e112e90ad458a84c0c04.tar.zst |
estimate bandwidth
Diffstat (limited to 'web/script/player/player.ts')
-rw-r--r-- | web/script/player/player.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/web/script/player/player.ts b/web/script/player/player.ts index 5c38dc8..08975b2 100644 --- a/web/script/player/player.ts +++ b/web/script/player/player.ts @@ -1,12 +1,14 @@ import { OVar, e } from "../jshelper/mod.ts"; import { JhlsMetadata, TimeRange } from "./jhls.d.ts"; +import { SegmentDownloader } from "./download.ts"; import { PlayerTrack } from "./track.ts"; export interface BufferRange extends TimeRange { status: "buffered" | "loading" | "queued" } export class Player { public video = e("video") - private media_source = new MediaSource(); + public media_source = new MediaSource(); public tracks = new OVar<PlayerTrack[]>([]); + public downloader: SegmentDownloader = new SegmentDownloader(); public position = new OVar(0) public duration = new OVar(1) @@ -66,8 +68,8 @@ export class Player { this.duration.value = metadata.duration this.video.src = URL.createObjectURL(this.media_source) this.media_source.addEventListener("sourceopen", async () => { - this.tracks.value.push(new PlayerTrack(this.media_source, this.node_id, 0, metadata.tracks[0])) - this.tracks.value.push(new PlayerTrack(this.media_source, this.node_id, 1, metadata.tracks[1])) + 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])) this.tracks.change() this.buffering_status.value = "Fetching initial segments..." this.update() |