From c2e50cef75712a119f9b6cafc9c12d2ed677d21e Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 7 Feb 2024 17:32:18 +0100 Subject: player: improve volume slider, fix native player button --- web/script/player/mod.ts | 12 +++++++++--- web/script/player/player.ts | 14 +++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'web/script') diff --git a/web/script/player/mod.ts b/web/script/player/mod.ts index fa83a2b..7a0e8fd 100644 --- a/web/script/player/mod.ts +++ b/web/script/player/mod.ts @@ -81,7 +81,13 @@ function initialize_player(el: HTMLElement, node_id: string) { slider.valueAsNumber = player.video.volume slider.onchange = () => player.video.volume = slider.valueAsNumber slider.onmousemove = () => player.video.volume = slider.valueAsNumber - return [e("div", { class: "jsp-controlgroup" }, e("label", "Volume", slider))] + return [e("div", { class: ["jsp-controlgroup", "jsp-volumecontrol"] }, + e("label", `Volume`), + e("span", { class: "jsp-volume" }, player.volume.map(v => + `${(v * 100).toFixed(2)}% | ${v == 0 ? "-∞" : (Math.log2(v) * 10).toFixed(2)}dB` as string + )), + slider + )] } new Popup(button, popups, () => @@ -119,7 +125,7 @@ function initialize_player(el: HTMLElement, node_id: string) { playersync_controls(sync_state, player), e("button", "Launch Native Player", { onclick: () => { - window.location.href = `jellynative://player-fullscreen/${window.location.protocol}//${window.location.host}/n/${encodeURIComponent(node_id)}/stream?format=hlsmaster` + window.location.href = `?kind=nativefullscreen` } }) )) @@ -257,4 +263,4 @@ function show_profile(profile: EncodingProfile): string { if (profile.video) return `codec=${profile.video.codec} br=${show.metric(profile.video.bitrate, "b/s")} w=${profile.video.width} preset=${profile.video.preset}` if (profile.subtitles) return `codec=${profile.subtitles.codec}` return `???` -} +} \ No newline at end of file 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(undefined) @@ -34,6 +35,17 @@ export class Player { } constructor(public node_id: string, public logger?: Logger) { + 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))) } -- cgit v1.2.3-70-g09d2