@moq/publish
Publish media to MoQ broadcasts. Provides both a JavaScript API and a <hang-publish> Web Component, plus an optional <hang-publish-ui> SolidJS overlay.
Installation
bash
bun add @moq/publish
# or
npm add @moq/publishWeb Component
html
<script type="module">
import "@moq/publish/element";
</script>
<hang-publish
url="https://relay.example.com/anon"
path="room/alice"
audio video controls>
<video muted autoplay></video>
</hang-publish>Attributes:
url(required) — Relay server URLpath(required) — Broadcast path/namedevice— "camera" or "screen" (default: "camera")audio— Enable audio capture (boolean)video— Enable video capture (boolean)controls— Show publishing controls (boolean)
UI Overlay
Import @moq/publish/ui for a SolidJS-powered overlay with device selection and publishing controls:
html
<script type="module">
import "@moq/publish/element";
import "@moq/publish/ui";
</script>
<hang-publish-ui>
<hang-publish
url="https://relay.example.com/anon"
path="room/alice"
audio video>
<video muted autoplay></video>
</hang-publish>
</hang-publish-ui>The <hang-publish-ui> element automatically discovers the nested <hang-publish> and wires up reactive controls.
JavaScript API
typescript
import * as Publish from "@moq/publish";
const broadcast = new Publish.Broadcast(connection, {
enabled: true,
name: "alice",
video: { enabled: true, device: "camera" },
audio: { enabled: true },
});
// Reactive controls
broadcast.video.device.set("screen");
broadcast.name.set("bob");Related Packages
- @moq/watch — Subscribe to and render MoQ broadcasts
- @moq/hang — Core media library (catalog, container, support)
- @moq/ui-core — Shared UI primitives
- @moq/lite — Core pub/sub transport protocol