useBroadcastContext
The useBroadcastContext
hook lets you build custom components which interact directly with the Broadcast state store.
The useStore
hook is from
zustand
,
and inherits all of the documentation for Zustand stores.
Features
- Flexible interaction with the broadcast state store
- Based on Zustand’s
useStore
hooks
Anatomy
Import the components and piece the parts together.
State
The useBroadcastContext
hook returns a Zustand store, which contains the
BroadcastState
.
aria
The ARIA text for the controls given the current state.
audio
Indicates whether the broadcast’s audio track is turned on.
enabled
Specifies whether the broadcast is currently active or in “preview” mode.
hydrated
Reflects whether the broadcast store is hydrated, indicating if initial data has been loaded into the state.
mediaDevices
A list of the current media devices (based on MediaDeviceInfo), which changes based on permissions or when a user starts sharing their display.
mediaStream
The MediaStream for the current broadcast, containing the audio and video tracks.
mounted
Whether the broadcast component is currently mounted in the DOM.
peerConnection
The RTCPeerConnection object for the broadcast, managing the connection between the local and remote peers.
status
The current status of the broadcast, which can be “live”, “pending”, or “idle”.
ingestUrl
The WHIP ingest URL used for the broadcast.
video
Indicates if the broadcast’s video track is turned on.
mediaDeviceIds
The IDs of the currently selected media devices.
__initialProps
The initial properties passed into the broadcast component. This is an internal object used by Broadcast.
__device
Information about the broadcast device’s capabilities and support. This is an internal object used by Broadcast, but can be used for detecting device capabilities.
__controls
The current state of broadcast controls. This is an internal object used by Broadcast.
__controlsFunctions
An object containing functions to manipulate the broadcast’s state, such as toggling audio/video, updating the media stream, and setting the peer connection.
These functions are internal - please refer to the UI Kit source code before interacting with these functions.