# HG changeset patch # User drewp@bigasterisk.com # Date 1681094225 25200 # Node ID f80f8c22752d34343e4b4f25259fe5c98bc9e0cd # Parent de93b9133acb8c91849c71d16be85ebd85358258 start PagePlayer, a singleton player that appears on top diff -r de93b9133acb -r f80f8c22752d src/PagePlayer.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/PagePlayer.ts Sun Apr 09 19:37:05 2023 -0700 @@ -0,0 +1,53 @@ +import { LitElement, html, css, PropertyValues } from "lit"; +import { customElement, property } from "lit/decorators.js"; +import "shaka-video-element"; + +interface CustomVideoElement extends HTMLVideoElement {} + +export interface ShakaVideoElement extends CustomVideoElement {} + +@customElement("page-player") +export class PagePlayer extends LitElement { + @property({ type: String }) manifest: string | undefined; + @property({ type: String }) size: "hidden" | "big" | "full" = "hidden"; + player!: Element; + static styles = [ + css` + div { + z-index: 2; + position: fixed; + } + div.full { + inset: 0; + } + div.big { + inset: 5em; + } + div.hidden { + display: none; + } + shaka-video { + width: 100%; + height: 100%; + } + `, + ]; + + updated(oldVals: PropertyValues) { + if (oldVals.get("size")) { + if (this.size == "hidden") { + const player = this.shadowRoot!.querySelector("shaka-video")! as ShakaVideoElement; + player.pause(); + } else if (this.size == "big") { + } else if (this.size == "full") { + } + } + } + render() { + return html` +
+ +
+ `; + } +} diff -r de93b9133acb -r f80f8c22752d src/VideoPage.ts --- a/src/VideoPage.ts Sun Apr 09 19:36:07 2023 -0700 +++ b/src/VideoPage.ts Sun Apr 09 19:37:05 2023 -0700 @@ -1,7 +1,9 @@ import { LitElement, html, css } from "lit"; import { customElement, property } from "lit/decorators.js"; +import { PagePlayer } from "./PagePlayer"; export { VideoSection } from "./VideoSection"; - +export { PagePlayer } from "./PagePlayer"; +import { ShakaVideoElement } from "./PagePlayer"; interface VideoFile { webRelPath: string; label: string; @@ -81,15 +83,43 @@ margin: 5px; border-bottom-right-radius: 29px; } + #scrim { + position: absolute; + background: #000000b5; + inset: 0; + display: none; + } `, ]; - // allow only 1 to play. embiggen like pbskids does. render() { return html`
${this.pathSegs.map((seg) => html`${seg.label}`)}
${this.subdirs.map((s) => html`
${s.label}
`)} - ${this.videos.map((v) => html``)} + ${this.videos.map( + (v) => html`` + )} +
+ `; } + playVideo(ev: CustomEvent) { + const player = this.shadowRoot!.querySelector("page-player")! as PagePlayer; + + player.manifest = ev.detail.manifest; + const sv = player.shadowRoot!.querySelector("shaka-video")! as ShakaVideoElement; + + sv.src = ev.detail.manifest; + sv.load().then(() => { + sv.play(); + }); + player.size = "big"; + this.shadowRoot!.querySelector("#scrim")!.style.display = "block"; + } + closePlayer() { + const player = this.shadowRoot!.querySelector("page-player")! as PagePlayer; + player.size = "hidden"; + + this.shadowRoot!.querySelector("#scrim")!.style.display = "none"; + } } diff -r de93b9133acb -r f80f8c22752d src/VideoSection.ts --- a/src/VideoSection.ts Sun Apr 09 19:36:07 2023 -0700 +++ b/src/VideoSection.ts Sun Apr 09 19:37:05 2023 -0700 @@ -18,34 +18,26 @@ color: white; width: 300px; } - #video.big { - z-index: 2; - position: fixed; - left: 0px; - top: 0px; - } `, ]; render() { - const vidCls = this.big ? "big" : ""; - const inx = 20, - iny = 50; - const inw = 300, - inh = 150; - const outw = 720, - outh = 480; - const scl = outh / inh; - const tx = (document.body.clientWidth - inw * scl) / 2, - ty = (document.body.clientHeight - inh * scl) / 2; - const style = this.big ? `transform: translate(${-inx - inw / 2}px,${-iny - inh / 2}px) scale(${outh / inh}) translate(${tx}px,${ty}px);` : ""; return html` -
+

${this.title}

-
`; } + click() { + this.dispatchEvent( + new CustomEvent("playVideo", { + detail: { + manifest: this.manifest, + zoomFrom: "my location", + }, + }) + ); + } updated() { // const el=this.querySelector("#video") // console.log(el.clientWidth);