diff --git a/js/publish/src/ui/element.ts b/js/publish/src/ui/element.ts index 8a9a3b40777..ea3c15fca02 100644 --- a/js/publish/src/ui/element.ts +++ b/js/publish/src/ui/element.ts @@ -100,26 +100,27 @@ export default class MoqPublishUi extends HTMLElement { player.append(scrimTop, center(effect, publish), chrome, panel); DOM.render(effect, this.#root, player); - // Keep the player box from jumping when video toggles off: reserve the - // last live preview's aspect ratio (defaults to 16:9) instead of snapping. + // Capture can be live without a preview, so size the box by what the slotted content renders, + // not by the capture alone. With nothing shown, reserve the last shown aspect ratio (initially + // 16:9) instead of snapping, and ignore an idle preview's placeholder size. let lastAspect = 16 / 9; + const rendered = new Signal(undefined); + const resize = new ResizeObserver(([entry]) => { + const { width, height } = entry.contentRect; + rendered.set(width > 0 && height > 0 ? width / height : undefined); + }); + resize.observe(publish); + effect.cleanup(() => resize.disconnect()); + effect.run((e) => { // A hidden camera stays open but shows no preview, so it sizes the box like no video at all. const capture = e.get(publish.controls.invisible) ? undefined : e.get(publish.video.in.capture); const src = capture ? e.get(capture.in.source) : undefined; - if (src) { + const aspect = e.get(rendered); + if (src && aspect) { + lastAspect = aspect; player.classList.remove("player--empty"); player.style.aspectRatio = ""; - const video = this.querySelector("video") as HTMLVideoElement | null; - if (video) { - const measure = () => { - if (video.videoWidth > 0 && video.videoHeight > 0) - lastAspect = video.videoWidth / video.videoHeight; - }; - measure(); - e.event(video, "loadedmetadata", measure); - e.event(video, "resize", measure); - } } else { player.style.aspectRatio = String(lastAspect); player.classList.add("player--empty"); diff --git a/quest/m1/README.md b/quest/m1/README.md index fc47a5146d6..2b69a4c812a 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -159,7 +159,6 @@ removed). - [Decoding from a track's first packet keeps its start](/quest/m1/opus-preskip.md) - moq-audio drops only OpusHead's pre-skip from a track's first packet, keeping the 80 ms warmup for mid-stream joins - [Container reads drop backfill](/quest/m1/read-backfill.md) - the JS container consumer drops groups below its read cursor like Rust - [Buffered playback subscribes in ascending order](/quest/m1/buffered-ascending.md) - a buffered `` asks for the oldest group first, so a voice reply's opening arrives first, and audio's head hold shrinks to the floor -- [The publish controls stay visible without a preview](/quest/m1/publish-controls.md) - ``'s controls no longer collapse with a live camera and no preview - [Push-to-talk loses no speech](/quest/m1/push-to-talk/README.md) - consumers hold a disabled rendition, and an unmute encodes at once with the mic still open - [Always-on encoding](/quest/m1/eager-encode/README.md) - publishers encode while enabled whatever the demand, so the past exists to fetch; on-demand is opt-in, and audio returns to it through a raw backbuffer - [TS fidelity and recovery](/quest/m1/ts-reliability/README.md) - both modes have explicit profiles, automated validation, loss tests, and a dedicated guide diff --git a/quest/m1/publish-controls.md b/quest/m1/publish-controls.md deleted file mode 100644 index d395e66373d..00000000000 --- a/quest/m1/publish-controls.md +++ /dev/null @@ -1,22 +0,0 @@ -# [XS] The publish controls stay visible without a preview - -## Goal - -``'s controls stay visible when a camera is live but the element -shows no `