This page describes the events that fire as a stream connects, how to use them for loading screens, and how to manage connection state manually.Documentation Index
Fetch the complete documentation index at: https://docs.streampixel.io/llms.txt
Use this file to discover all available pages before exploring further.
Event sequence
When a stream connects successfully, events fire in this order:webRtcAutoConnect— Auto-connect initiated (only ifAutoConnect: true)webRtcConnecting— WebRTC peer connection is being establishedwebRtcSdp— SDP offer/answer exchanged between browser and UEwebRtcConnected— Peer connection established, media channels openstreamLoading— Video data arriving from UEplayStream— Video is about to start playbackvideoInitialized— Video element is ready (viaappStream.onVideoInitialized)
Listening for events
videoInitialized is handled via a callback (appStream.onVideoInitialized), not through addEventListener like the other events. This is because it fires from the application wrapper, not from the pixelStreaming instance.Building a loading screen
Map each event to a progress percentage for a smooth loading experience:Failure events
webRtcFailed
Fires when the WebRTC connection fails to establish.
webRtcDisconnected
Fires when an established connection drops.
When automatic reconnection is active,
webRtcDisconnected may fire during the reconnection process. Check reconnectStream state to differentiate between a temporary disconnect (reconnecting) and a permanent one. See Reconnection.Manual connection control
IfAutoConnect is false, connect manually:
Mobile background handling
Next steps
Reconnection
Handle WebSocket drops with the automatic reconnection state machine.
Return values
Reference for
pixelStreaming, appStream, and the other returned objects.