Page Content
Channel APIs
Channel Viewer
Join a channel and automatically view the most recent content published to that channel.
JavaScript
var videoElement = document.getElementsByTagName('video')[0];
var channel = phenix.Channels.createChannel({
videoElement: videoElement,
token: token,
});
channel.authorized.subscribe(function (authorized) {
if (!authorized) {
// Channel is unauthorized, skipping retry of start. Please provide a new token and invoke channel.start()
}
});
channel.autoMuted.subscribe(function (autoMuted) {
if (autoMuted) {
// Show unmute button so a user-triggered action triggers channel.unmute()
}
});
channel.autoPaused.subscribe(function (autoPaused) {
if (autoPaused) {
// Show play button so a user-triggered action triggers channel.play()
}
});
Channel Viewer Parameters
Name | Type | Description |
---|---|---|
options (required) | CreateChannelOptions | Options to use when joining the channel |
Create Channel Options
Name | Type | Default Value | Description |
---|---|---|---|
videoElement (required) | HTMLMediaElement | Video element that will show the stream | |
token (required) | String | EdgeToken used to connect and authenticate to the platform and subscribe to a stream. |
Creating an EdgeToken
To generate an EdgeToken you must have a channel ID or an alias. Check out our EdgeAuth libraries and documentation for information on how to generate edge tokens on your backend. This is the recommended way to issue authentication tokens.
[object Channel]
Name | Type | Description |
---|---|---|
authorized | Observable(boolean) | Observable for channel authorized state. |
autoMuted | Observable(boolean) | Observable for channel autoMuted state. |
autoPaused | Observable(boolean) | Observable for channel autoPaused state. |
clearBitrateLimit | Function | Clear bitrate limit that was prior set. View example on Github |
failureCount | Observable(number) | Observable for channel failureCount. |
loading | Observable(boolean) | Observable is channel loading. |
mediaStream | Observable(MediaStream) | Observable for MediaStream changes. |
online | Observable(boolean) | Observable is channel online. |
playing | Observable(boolean) | Observable is channel playing. |
rtcStatistics | Observable(RtcMonitorStatistic) | Observable for channel RTC stats check. |
setBitrateLimit | Function | Set a bitrate limit for the received stream. View example on Github |
standby | Observable(boolean) | Observable is channel in standby mode. |
state | Observable(ChannelState) | Observable for channel state changes. |
stopped | Observable(boolean) | Observable is channel stopped. |
streamId | String | Stream ID. |
token | String | EdgeToken used to connect and authenticate to the platform and subscribe to a stream. |
tokenExpiring | Observable(boolean) | Observable that returns tokenExpiring state. |
videoElement | VideoElement | Video element that will show the stream. |
Channel State
Role | Value | Description |
---|---|---|
Offline | 1 | Channel is in Offline state. |
Starting | 2 | Channel is already starting, skipping retry of start. |
Paused | 3 | Channel is paused, skipping retry of start. Please invoke play(). |
Playing | 4 | Channel is playing, skipping retry of start. |
Recovering | 5 | Channel tries to recover from some state will retry to reconnect. |
Reconnecting | 6 | Channel is reconnecting after being disconnected. |
StandBy | 7 | Channel will try to connect to the stream in StandBy interval (15000ms). |
Stopped | 8 | Channel is stopped, skipping retry of start. |
Unauthorized | 9 | Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start(). |
GeoRestricted | 10 | Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start(). |
GeoBlocked | 11 | Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start(). |
Error | 12 | Channel is not able to subscribe to stream due to a general failed subscription. |
UnsupportedFeature | 13 | Channel is not supporting the requested feature on this browser. This can be due to browser limitations or missing configuration for a player for the requested capability. |
Rtc Monitor Statistic Object
Property | Value |
---|---|
audio | RtcStatistic Audio Object |
video | RtcStatistic Video Object |
RtcStatistic Audio Object
Property | Type | Description |
---|---|---|
ssrc | Number | An integer which uniquely identifies the source of the RTP stream. |
mediaType | String | Kind/Media type of the stream. |
timestamp | Number | UNIX time stamp of when the statistics is captured. |
bytesReceived | Number | Bytes received. |
packetsLost | Number | Packets lost. |
packetsReceived | Number | Packets received. |
codec | String | Codec used to decode data. |
roundTripTime | Number | Round Trip Time of the webRTC connection. |
RtcStatistic Video Object
Property | Type | Description |
---|---|---|
ssrc | Number | An integer which uniquely identifies the source of the RTP stream. |
mediaType | String | Kind/Media type of the stream. |
timestamp | Number | UNIX time stamp of when the statistics is captured. |
bytesReceived | Number | Bytes received. |
framesDecoded | Number | Frames decoded. |
packetsLost | Number | Packets lost. |
packetsReceived | Number | Packets received. |
codec | String | Codec used to decode data. |
fps | Number | Frames per second. |
roundTripTime | Number | Round Trip Time of the webRTC connection. |
Limit Bitrate
Limit the bitrate limit for the received stream. View example on Github
Parameters
Property | Type | Description |
---|---|---|
bitrateLimitInBitsPerSecond | Number | Bitrate limit of the stream. |
JavaScript
var bitrateLimitInBitsPerSecond = 500000;
channel.setBitrateLimit(bitrateLimitInBitsPerSecond);
Clear Bitrate Limit
Clear bitrate limit that was prior set. View example on Github
JavaScript
channel.clearBitrateLimit();
v2023-12-04T20:36:01.000Z