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.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/web/script/player/player.ts b/web/script/player/player.ts
index a5bccdb..367ae04 100644
--- a/web/script/player/player.ts
+++ b/web/script/player/player.ts
@@ -23,6 +23,7 @@ export class Player {
public position = new OVar(0)
public duration = new OVar(1)
+ public volume = new OVar(0)
public playing = new OVar(false)
public canplay = new OVar(false)
public error = new OVar<string | undefined>(undefined)
@@ -34,6 +35,17 @@ export class Player {
}
constructor(public node_id: string, public logger?: Logger<string>) {
+ this.volume.value = this.video.volume
+ let skip_change = false;
+ this.volume.onchange(v => {
+ if (!skip_change) this.video.volume = v
+ skip_change = false
+ })
+ this.video.onvolumechange = () => {
+ skip_change = true;
+ this.volume.value = this.video.volume
+ }
+
this.video.onloadedmetadata = () => { }
this.video.ondurationchange = () => { }
this.video.ontimeupdate = () => {
@@ -129,7 +141,7 @@ export class Player {
this.set_pers()
})
}
-
+
async update(newt?: number) {
await Promise.all(this.active_tracks.value.map(t => t.update(newt ?? this.video.currentTime)))
}