Page Content
Channel APIs
Channel Viewer
Join a channel and automatically view the most recent content published to that channel.
View interactive and editable example on JSFiddle
JavaScript
1var videoElement = document.getElementsByTagName('video')[0];2var channel = phenix.Channels.createChannel({3 videoElement: videoElement,4 token: token,5});67channel.authorized.subscribe(function (authorized) {8 if (!authorized) {9 // Channel is unauthorized, skipping retry of start. Please provide a new token and invoke channel.start()10 }11});1213channel.autoMuted.subscribe(function (autoMuted) {14 if (autoMuted) {15 // Show unmute button so a user-triggered action triggers channel.unmute()16 }17});1819channel.autoPaused.subscribe(function (autoPaused) {20 if (autoPaused) {21 // Show play button so a user-triggered action triggers channel.play()22 }23});
Channel Viewer Parameters
Name | Type | Description |
---|---|---|
options (required) | CreateChannelOptions | Options to join channel with |
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 EdgeToken
To generate EdgeToken you must have a channel ID or an alias. Check out our EdgeAuth libraries for 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. |
online | Observable(boolean) | Observable is channel online. |
playing | Observable(boolean) | Observable is channel playing. |
rtcStats | 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 that returns channel current state. |
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
1var bitrateLimitInBitsPerSecond = 500000;23 channel.setBitrateLimit(bitrateLimitInBitsPerSecond);
Clear Bitrate Limit
Clear bitrate limit that was prior set. View example on Github
JavaScript
1channel.clearBitrateLimit();
v2023-01-31T21:25:10