Embedding A Channel
A channel references by a permalink can be embedded via <iframe>
. Additional options are required to assure smooth playback across all platforms.
<iframe
src="<permalink>"
frameborder="0"
allow="autoplay; encrypted-media"
allowfullscreen
webkitallowfullscreen
>
<p>Your browser does not support iframes.</p>
</iframe>
Permalinks contain EdgeAuth tokens. To detect the case when the edge auth token has expired and must be refreshed, listen for the subscriberCallback
with status unauthorized
.
Lifecycle Events
You can listen to lifecycle events for the embedded channel. The channel uses the postMessage
API to securely send notifications to the parent window.
window.addEventListener('message', receiveMessage, false);
function receiveMessage(event) {
console.log({ timeStamp: event.timeStamp, data: event.data });
}
Types of Lifecycle Events
Lifecycle events are emitted for the view channel API, both for joining the channel and stream subscriptions.
Joining A Channel
After the channel joined successfully, it emits a lifecycle event for the join channel callback.
{
"timeStamp": 312.5,
"data": {
"channelAlias": "embedded_channel",
"action": "joinChannel",
"type": "joinChannelCallback",
"status": "ok"
}
}
In case there is an issue joining the channel, the status will be one of the join channel callback status codes.
Subscribing to A Stream
Subsequently, when the channel subscribed to the active stream, it emits a lifecycle event for the subscriber callback.
{
"timeStamp": 692.3,
"data": {
"channelAlias": "embedded_channel",
"action": "joinChannel",
"type": "subscriberCallback",
"status": "ok"
}
}
In case there is an issue subscribing to an active stream, the status will be one of the join channel subscriber callback status codes.