# HG changeset patch # User drewp@bigasterisk.com # Date 1733475753 28800 # Node ID df51269bcef4c8c9b086494da040fef8708520ae # Parent 239a83d46d48daeebeaaab5964b10314f6c3d4de fix back/fwd nav and player loading diff -r 239a83d46d48 -r df51269bcef4 src/VideoPage.ts --- a/src/VideoPage.ts Fri Dec 06 01:01:05 2024 -0800 +++ b/src/VideoPage.ts Fri Dec 06 01:02:33 2024 -0800 @@ -1,12 +1,13 @@ +import { Router } from "@lit-labs/router"; import { LitElement, PropertyValues, TemplateResult, css, html, unsafeCSS } from "lit"; -import { customElement, property } from "lit/decorators.js"; +import { customElement, property, queryAsync } from "lit/decorators.js"; import { PagePlayer, ShakaVideoElement } from "./PagePlayer"; import maincss from "./main.css?inline"; export { SlProgressBar } from "@shoelace-style/shoelace"; export { PagePlayer } from "./PagePlayer"; +export { VBreadcrumbs } from "./VBreadcrumbs"; export { VideoSection } from "./VideoSection"; -import { Routes, Router } from "@lit-labs/router"; -export { VBreadcrumbs } from "./VBreadcrumbs"; + interface VideoFile { webRelPath: string; webDataPath: string; @@ -18,9 +19,12 @@ path: string; } -interface VideoListings { +interface PageData { + webDirRelPath: string; + dirLabel: string; videos: VideoFile[]; subdirs: Subdir[]; + autoplay: VideoFile | null; } function subdirQuery(subdir: string): string { @@ -29,39 +33,24 @@ class route { path = "/video/*"; - videoListings: VideoListings | null = null; - showVid: string | null = null; - dirName?: string; - - link(wrp: string): string { - return "/video/" + wrp; - } + pageData: PageData | null = null; async enter(params: { [key: string]: string | undefined }): Promise { - const webRelPath = "/" + params[0]!; - this.dirName = webRelPath.replace(/.*\/([^/]+)/, "$1"); + const webRelPath = "/" + params[0]!; // could be /a/dir/ or /a/video + console.log("enter", webRelPath); const resp = await fetch("/video/api/videos?" + subdirQuery(webRelPath)); if (resp.status == 404) { return false; } - this.videoListings = await resp.json(); - - if (webRelPath.endsWith("/")) { - this.showVid = null; - } else { - this.showVid = webRelPath; - } + this.pageData = await resp.json(); + if (!this.pageData) return false; return true; } render(p: { [key: string]: string | undefined }) { - return html``; + console.log("render", this.pageData); + return html``; } } @@ -70,13 +59,23 @@ static styles = [unsafeCSS(maincss)]; private _router = new Router(this, [new route()], {}); + constructor() { + super(); + window.rr = this._router; + } + render() { - const requestedPath = "/" + this._router.params[0]; - + const pd = (this._router.routes[0] as route).pageData; + if (!pd) { + console.log("no page data", this._router.routes); + return html`loading...`; + throw new Error("no page data"); + } + console.log("yes page data", pd); return html`
- - + +
${this._router.outlet()}