Parent Window Communication

When you embed the Low Code Video application inside an IFRAME, the embed and the parent page can communicate bidirectionally using the browser's postMessage API. This turns the embedded video session into an interactive component that is aware of your application — not just a passive frame.

Communication flows in two directions:

How It Works

Both directions use the standard browser window messaging model. Your parent page holds a reference to the IFRAME's contentWindow and calls postMessage() on it to send an action. The embed sends notifications back using the same mechanism, and your parent page receives them by listening for the notification event on window.

All messages are JSON-serialised strings. The structure of an action sent from the parent always contains an "action" key and, where applicable, a "data" object:

// Sending an action from the parent page to the embed
const message = JSON.stringify({
  action: "action-name",
  data: { /* optional payload */ }
});

document.getElementById("videoIframe").contentWindow.postMessage(message, '*');
// Replace "videoIframe" with the actual id of your IFRAME element

A notification received by the parent from the embed follows this structure:

// Listening for notifications from the embed on the parent page
window.addEventListener('notification', function(e) {
  const decoded = JSON.parse(e);

  switch (decoded.notification) {
    case 'room-connected':
      // handle room connected
      break;
    case 'user-connected':
      // handle user joined
      break;
  }
});
Subscribe before you listen. The embed does not send most notifications automatically. You must first send a subscribe-notification action to opt in to the notification groups you want to receive. The only exceptions are room connection events and media access events, which are always emitted.
Actions — Parent to Embed

Notification Subscription

Before the embed sends notifications to the parent, the parent must subscribe to one or more notification groups. Each group covers a category of events. Subscribing to a group means you receive all events in that group until you explicitly unsubscribe.

Subscribe to Notifications

Send this action to start receiving notifications from the specified groups:

const message = JSON.stringify({
  action: "subscribe-notification",
  data: [
    "live-streaming",
    "room-connection",
    "user-connection",
    "stream-updates",
    "messaging"
  ]
});

document.getElementById("videoIframe").contentWindow.postMessage(message, '*');

Available notification groups:

GroupDescription
live-streamingEvents when live streaming starts or stops.
room-connectionEvents for room connection, disconnection, and reconnection.
user-connectionEvents when any user joins or leaves the room.
stream-updatesEvents for local stream attribute changes — mute/unmute of audio and video tracks.
messagingEvents for custom signalling and chat messages.

Unsubscribe from Notifications

To stop receiving notifications from specific groups:

const message = JSON.stringify({
  action: "unsubscribe-notification",
  data: [
    "live-streaming",
    "room-connection"
  ]
});

document.getElementById("videoIframe").contentWindow.postMessage(message, '*');

To unsubscribe from all notification groups at once, pass an empty array:

const message = JSON.stringify({
  action: "unsubscribe-notification",
  data: []
});

document.getElementById("videoIframe").contentWindow.postMessage(message, '*');

Room Connection

Disconnect from Room

Instructs the embed to disconnect the current user from the video session. You can optionally show a confirmation prompt before disconnecting.

With a confirmation prompt:

const message = JSON.stringify({
  action: "disconnect-room",
  data: { alert: true }
});

document.getElementById("videoIframe").contentWindow.postMessage(message, '*');

Immediately, without a prompt:

const message = JSON.stringify({
  action: "disconnect-room",
  data: { alert: false }
});

document.getElementById("videoIframe").contentWindow.postMessage(message, '*');
FieldTypeDescription
alertBooleantrue — show a confirmation prompt; false — disconnect immediately.

Destroy Video Session

A moderator can end the session for all participants by destroying the room. All connected users are disconnected automatically.

This is a moderator-only action. Send it only from the embed loaded with the Moderator URL. Sending it from a participant embed has no effect.

With a confirmation prompt:

const message = JSON.stringify({
  action: "destroy-room",
  data: { alert: true }
});

document.getElementById("videoIframe").contentWindow.postMessage(message, '*');

Immediately, without a prompt:

const message = JSON.stringify({
  action: "destroy-room",
  data: { alert: false }
});

document.getElementById("videoIframe").contentWindow.postMessage(message, '*');

Stream Updates

Control the local user's audio and video tracks from the parent page.

Mute Video

Stops the video track on the local stream. The stream continues, but no video data is sent.

const message = JSON.stringify({ action: "mute-video" });
document.getElementById("videoIframe").contentWindow.postMessage(message, '*');

Unmute Video

Restores the video track on the local stream.

const message = JSON.stringify({ action: "unmute-video" });
document.getElementById("videoIframe").contentWindow.postMessage(message, '*');

Mute Audio

Stops the audio track on the local stream.

const message = JSON.stringify({ action: "mute-audio" });
document.getElementById("videoIframe").contentWindow.postMessage(message, '*');

Unmute Audio

Restores the audio track on the local stream.

const message = JSON.stringify({ action: "unmute-audio" });
document.getElementById("videoIframe").contentWindow.postMessage(message, '*');

Live Streaming

These actions start and stop HLS/RTMP live streaming of the current video session. You provide the RTMP endpoint and key that the streaming service (such as YouTube Live or any RTMP destination) gives you.

Live streaming actions are moderator-only. Send them only from the embed loaded with the Moderator URL.

Start Live Streaming

const message = JSON.stringify({
  action: "start-live-streaming",
  data: {
    name: "YouTube",
    rtmp_endpoint: "rtmp://a.rtmp.youtube.com/live2",
    rtmp_key: "YOUR_STREAM_KEY"
  }
});

document.getElementById("videoIframe").contentWindow.postMessage(message, '*');
FieldDescription
nameA human-readable label for this stream destination.
rtmp_endpointThe RTMP ingest URL provided by the streaming service.
rtmp_keyThe stream key or token for authenticating with the streaming service.

Stop Live Streaming

Stops all active live streams for the current session.

const message = JSON.stringify({ action: "stop-live-streaming" });
document.getElementById("videoIframe").contentWindow.postMessage(message, '*');

Change Video Layout

Switch the video grid between gallery view and leader view. You can target only the RTMP stream output, or apply the change to all endpoints simultaneously.

const message = JSON.stringify({
  action: "change-layout",
  data: {
    target: "all",
    layout: "leader"
  }
});

document.getElementById("videoIframe").contentWindow.postMessage(message, '*');
FieldValuesDescription
target rtmp / all rtmp changes the layout only in the RTMP stream output. all changes the layout at all endpoints.
layout gallery / leader The target layout.

Custom Signalling

Broadcast a custom data payload to all users in the session. EnableX does not interpret the payload — it simply relays it to every connected endpoint. This is a lightweight signalling mechanism for passing application-specific messages between participants.

const message = JSON.stringify({
  action: "signal",
  data: {
    /* Define your own data structure here */
    type: "poll-question",
    question: "Which feature do you use most?"
  }
});

document.getElementById("videoIframe").contentWindow.postMessage(message, '*');
Keep custom signal payloads small. The signal is broadcast to all participants and is not stored by EnableX.
Notifications — Embed to Parent

The embed fires these notifications to the parent window. Unless otherwise noted, you must subscribe to the relevant notification group before the embed will send that notification. See Subscribe to Notifications above.

Subscription Notifications

These two notifications are sent automatically whenever you subscribe or unsubscribe — no prior subscription is required.

Notification Subscribed

Confirms the groups you have successfully subscribed to.

{
  "notification": "notification-subscribed",
  "data": [
    "live-streaming",
    "room-connection"
  ]
}

Notification Unsubscribed

Confirms the groups you have unsubscribed from.

{
  "notification": "notification-unsubscribed",
  "data": [
    "live-streaming",
    "room-connection"
  ]
}

Room Connection Notifications

Sent when the embed's connection to the video room changes state. The room-connected, room-not-connected, and room-disconnected notifications are always emitted — no subscription required. The room-reconnected notification requires subscribing to the room-connection group.

Room Connected

{
  "notification": "room-connected",
  "data": {
    "room_name": "John's Room",
    "conf_num": "SESSION_ID"
  }
}
FieldDescription
room_nameName of the video room.
conf_numUnique identifier of this session instance (Conference Number).

Room Not Connected

{
  "notification": "room-not-connected",
  "data": {}
}

Room Disconnected

{
  "notification": "room-disconnected",
  "data": {
    "message": "Reason for disconnection"
  }
}

Possible disconnection reasons include:

Room Reconnected

Requires subscription to the room-connection group.

{
  "notification": "room-reconnected"
}

User Connection Notifications

Fired when any participant joins or leaves the room. Requires subscription to the user-connection group.

User Connected

{
  "notification": "user-connected",
  "data": {
    "clientId": "UNIQUE_CLIENT_ID",
    "name": "Alice",
    "role": "participant"
  }
}

User Disconnected

{
  "notification": "user-disconnected",
  "data": {
    "clientId": "UNIQUE_CLIENT_ID",
    "name": "Alice",
    "role": "participant"
  }
}
FieldDescription
clientIdUnique identifier assigned to this user for the session.
nameDisplay name of the user.
roleRole of the user: moderator, participant, viewer, or audience.

Stream Update Notifications

Fired when the local user's audio or video track changes state. Requires subscription to the stream-updates group.

{ "notification": "video-muted" }
{ "notification": "video-unmuted" }
{ "notification": "audio-muted" }
{ "notification": "audio-unmuted" }

Live Streaming Notifications

Requires subscription to the live-streaming group.

Live Streaming Started

{
  "notification": "live-streaming-started",
  "data": {
    "name": "YouTube",
    "rtmp_endpoint": "rtmp://a.rtmp.youtube.com/live2",
    "rtmp_key": "YOUR_STREAM_KEY"
  }
}

Live Streaming Stopped

{
  "notification": "live-streaming-stopped",
  "data": {}
}

Media Access Notifications

These notifications are always emitted — no subscription required. They report whether the embed was able to access the user's camera and microphone.

Media Access Denied

// Room did not connect due to media access being denied
{
  "notification": "media-access-denied",
  "data": {
    "message": "Media access denied. Room not connected."
  }
}

// Room connected but without camera/mic access
{
  "notification": "media-access-denied",
  "data": {
    "message": "Mic and Camera access denied"
  }
}

Camera Access

{ "notification": "camera-access-allowed", "data": {} }
{ "notification": "camera-access-denied",  "data": {} }

Microphone Access

{ "notification": "mic-access-allowed", "data": {} }
{ "notification": "mic-access-denied",  "data": {} }

Custom Signal Received

Fired when the embed receives a custom signal broadcast from another participant. Requires subscription to the messaging group.

{
  "notification": "signal-received",
  "data": {
    /* Your custom data structure, as sent by the broadcaster */
  }
}