aboutsummaryrefslogtreecommitdiff
path: root/ui/client-scripts/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-02-19 01:25:16 +0100
committermetamuffin <metamuffin@disroot.org>2026-02-19 01:25:16 +0100
commita197ab4dc250311255056d4b36a6da8653e1040c (patch)
treeaebdccdc4ff55cf0e54499214c532cea26dca493 /ui/client-scripts/src
parent10290e706ac0190c874e8b6117cb2c11b5e6e504 (diff)
downloadjellything-a197ab4dc250311255056d4b36a6da8653e1040c.tar
jellything-a197ab4dc250311255056d4b36a6da8653e1040c.tar.bz2
jellything-a197ab4dc250311255056d4b36a6da8653e1040c.tar.zst
several player fixes
Diffstat (limited to 'ui/client-scripts/src')
-rw-r--r--ui/client-scripts/src/player/mod.ts18
-rw-r--r--ui/client-scripts/src/player/player.ts6
2 files changed, 11 insertions, 13 deletions
diff --git a/ui/client-scripts/src/player/mod.ts b/ui/client-scripts/src/player/mod.ts
index 9b32c26..bb615dd 100644
--- a/ui/client-scripts/src/player/mod.ts
+++ b/ui/client-scripts/src/player/mod.ts
@@ -10,18 +10,16 @@ import { Logger } from "../jshelper/src/log.ts";
import { Player } from "./player.ts";
import { Popup } from "./popup.ts";
import { Playersync, playersync_controls } from "./sync.ts"
-import { Chapter } from "./types_node.ts";
import { FormatInfo, TrackKind } from "./types_stream.ts";
globalThis.addEventListener("DOMContentLoaded", () => {
- if (document.getElementById("player")) {
+ const video = document.getElementById("player");
+ if (video) {
if (globalThis.location.search.search("nojsp") != -1) return
if (!globalThis.MediaSource) return alert("Media Source Extension API required")
const node_id = globalThis.location.pathname.split("/")[2];
- document.getElementById("player")?.remove();
- // document.getElementsByClassName("playerconf").item(0)?.remove()
globalThis.dispatchEvent(new Event("navigationrequiresreload"))
- document.getElementById("main")!.prepend(initialize_player(node_id))
+ document.getElementById("main")!.prepend(initialize_player(node_id, video as HTMLVideoElement))
}
})
@@ -50,10 +48,12 @@ function get_query_start_time() {
return x
}
-function initialize_player(node_id: string): HTMLElement {
+type Chapter = { time_start: number, time_end: number, labels: string[][] }
+
+function initialize_player(node_id: string, video: HTMLVideoElement): HTMLElement {
const logger = new Logger<string>(s => e("p", s))
const start_time = get_query_start_time() ?? 0 // TODO get_continue_time(ndata.userdata.watched);
- const player = new Player(`/n/${encodeURIComponent(node_id)}/stream`, `/n/${encodeURIComponent(node_id)}/poster`, start_time, logger)
+ const player = new Player(video, `/n/${node_id}/stream`, start_time, logger)
const show_stats = new OVar(false);
const idle_inhibit = new OVar(false)
const sync_state = new OVar<Playersync | undefined>(undefined)
@@ -339,9 +339,9 @@ function send_player_progress(node_id: string, player: Player) {
const start = nt < 1 * 60
const end = nt > player.duration.value - 5 * 60
- if (!start) fetch(`/n/${encodeURIComponent(node_id)}/progress?t=${nt}`, { method: "POST" })
+ // if (!start && !send_watched) fetch(`/n/${node_id}/progress?t=${nt}`, { method: "POST" })
if (end && !sent_watched) {
- fetch(`/n/${encodeURIComponent(node_id)}/watched?state=watched`, { method: "POST" })
+ // fetch(`/n/${node_id}/watched?state=watched`, { method: "POST" })
sent_watched = true;
}
}
diff --git a/ui/client-scripts/src/player/player.ts b/ui/client-scripts/src/player/player.ts
index 4f59f8a..ab0313f 100644
--- a/ui/client-scripts/src/player/player.ts
+++ b/ui/client-scripts/src/player/player.ts
@@ -4,7 +4,7 @@
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
/// <reference lib="dom" />
-import { OVar, e } from "../jshelper/mod.ts";
+import { OVar } from "../jshelper/mod.ts";
import { SegmentDownloader } from "./download.ts";
import { PlayerTrack } from "./track/mod.ts";
import { Logger } from "../jshelper/src/log.ts";
@@ -13,7 +13,6 @@ import { StreamInfo, TimeRange, TrackInfo } from "./types_stream.ts";
export interface BufferRange extends TimeRange { status: "buffered" | "loading" | "queued" }
export class Player {
- public video = e("video")
public media_source = new MediaSource();
public streaminfo?: StreamInfo;
public tracks?: TrackInfo[];
@@ -33,8 +32,7 @@ export class Player {
if (s) this.cancel_buffering_pers = this.logger?.log_persistent(s)
}
- constructor(public base_url: string, poster: string, private start_time: number, public logger?: Logger<string>) {
- this.video.poster = poster
+ constructor(public video: HTMLVideoElement, public base_url: string, private start_time: number, public logger?: Logger<string>) {
this.volume.value = this.video.volume
let skip_change = false;
this.volume.onchange(v => {