aboutsummaryrefslogtreecommitdiff
path: root/web/script/player/player.ts
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-01-15 18:32:31 +0100
committermetamuffin <metamuffin@disroot.org>2024-01-15 18:32:31 +0100
commit36022cedfb1f34f086f20f7846cb68e382f5a7ce (patch)
tree89030d61c93b6736a8bb3f93853c10bc487cb974 /web/script/player/player.ts
parent31c3529ec2f8d934711d1ad2547e73c84a59878f (diff)
downloadjellything-36022cedfb1f34f086f20f7846cb68e382f5a7ce.tar
jellything-36022cedfb1f34f086f20f7846cb68e382f5a7ce.tar.bz2
jellything-36022cedfb1f34f086f20f7846cb68e382f5a7ce.tar.zst
track select ui in jsp-
Diffstat (limited to 'web/script/player/player.ts')
-rw-r--r--web/script/player/player.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/web/script/player/player.ts b/web/script/player/player.ts
index d76d8cb..2ba2e1d 100644
--- a/web/script/player/player.ts
+++ b/web/script/player/player.ts
@@ -93,8 +93,8 @@ export class Player {
this.video.src = URL.createObjectURL(this.media_source)
this.media_source.addEventListener("sourceopen", async () => {
this.set_pers("Downloading track indecies...")
- await this.set_track_enabled(0, true)
- await this.set_track_enabled(1, true)
+ await this.set_track_enabled(0, true, false)
+ await this.set_track_enabled(1, true, false)
this.set_pers("Downloading initial segments...")
this.update()
await this.canplay.wait_for(true)
@@ -105,14 +105,15 @@ export class Player {
await Promise.all(this.active_tracks.value.map(t => t.update(newt ?? this.video.currentTime)))
}
- async set_track_enabled(index: number, state: boolean) {
+ async set_track_enabled(index: number, state: boolean, update = true) {
console.log(`(${index}) set enabled ${state}`);
const active_index = this.active_tracks.value.findIndex(t => t.track_index == index)
- if (!state && active_index !== undefined) {
+ if (!state && active_index != -1) {
const [track] = this.active_tracks.value.splice(active_index, 1)
- track.destroy()
- } else if (state && active_index === undefined) {
+ track.abort.abort()
+ } else if (state && active_index == -1) {
this.active_tracks.value.push((await PlayerTrack.new(this, this.node_id, index, this.tracks![index]))!)
+ if (update) await this.update()
}
this.active_tracks.change()
}