• Skip to Search
  • Skip to Content
  • Skip to Side Navigation
Getting StartedSDK ReferenceGlossary
  • Home
  • Getting Started
  • SDK Reference
  • Portal
  • How-To
  • Troubleshooting
  • FAQs
  • Reference
  • Glossary
REST API
Web SDK
Android SDK
iOS SDK
Unity SDK
React Native SDK
EdgeAuth SDK
  • Overview
  • Web SDK 1.0
    • Overview
    • Express API
    • Low-Level API
  • Web SDK 2.0
    • Overview
    • Channel
  • Browser Support
  • Web Examples
  • Release Notes

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

View example on Github

JavaScript
1var videoElement = document.getElementsByTagName('video')[0];
2var channel = phenix.Channels.createChannel({
3 videoElement: videoElement,
4 token: token,
5});
6
7channel.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});
12
13channel.autoMuted.subscribe(function (autoMuted) {
14 if (autoMuted) {
15 // Show unmute button so a user-triggered action triggers channel.unmute()
16 }
17});
18
19channel.autoPaused.subscribe(function (autoPaused) {
20 if (autoPaused) {
21 // Show play button so a user-triggered action triggers channel.play()
22 }
23});

Channel Viewer Parameters

NameTypeDescription
options (required)CreateChannelOptionsOptions to join channel with

Create Channel Options

NameTypeDefault ValueDescription
videoElement (required)HTMLMediaElementVideo element that will show the stream
token (required)StringEdgeToken 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]

NameTypeDescription
authorizedObservable(boolean)Observable for channel authorized state.
autoMutedObservable(boolean)Observable for channel autoMuted state.
autoPausedObservable(boolean)Observable for channel autoPaused state.
clearBitrateLimitFunctionClear bitrate limit that was prior set. View example on Github
failureCountObservable(number)Observable for channel failureCount.
loadingObservable(boolean)Observable is channel loading.
onlineObservable(boolean)Observable is channel online.
playingObservable(boolean)Observable is channel playing.
rtcStatsObservable(RtcMonitorStatistic)Observable for channel RTC stats check.
setBitrateLimitFunctionSet a bitrate limit for the received stream. View example on Github
standbyObservable(boolean)Observable is channel in standby mode.
stateObservable(ChannelState)Observable that returns channel current state.
stoppedObservable(boolean)Observable is channel stopped.
streamIdStringStream ID.
tokenStringEdgeToken used to connect and authenticate to the platform and subscribe to a stream.
tokenExpiringObservable(boolean)Observable that returns tokenExpiring state.
videoElementVideoElementVideo element that will show the stream.

Channel State

RoleValueDescription
Offline1Channel is in Offline state.
Starting2Channel is already starting, skipping retry of start.
Paused3Channel is paused, skipping retry of start. Please invoke play().
Playing4Channel is playing, skipping retry of start.
Recovering5Channel tries to recover from some state will retry to reconnect.
Reconnecting6Channel is reconnecting after being disconnected.
StandBy7Channel will try to connect to the stream in StandBy interval (15000ms).
Stopped8Channel is stopped, skipping retry of start.
Unauthorized9Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start().
GeoRestricted10Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start().
GeoBlocked11Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start().
Error12Channel is not able to subscribe to stream due to a general failed subscription.
UnsupportedFeature13Channel 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

PropertyValue
audioRtcStatistic Audio Object
videoRtcStatistic Video Object

RtcStatistic Audio Object

PropertyTypeDescription
ssrcNumberAn integer which uniquely identifies the source of the RTP stream.
mediaTypeStringKind/Media type of the stream.
timestampNumberUNIX time stamp of when the statistics is captured.
bytesReceivedNumberBytes received.
packetsLostNumberPackets lost.
packetsReceivedNumberPackets received.
codecStringCodec used to decode data.
roundTripTimeNumberRound Trip Time of the webRTC connection.

RtcStatistic Video Object

PropertyTypeDescription
ssrcNumberAn integer which uniquely identifies the source of the RTP stream.
mediaTypeStringKind/Media type of the stream.
timestampNumberUNIX time stamp of when the statistics is captured.
bytesReceivedNumberBytes received.
framesDecodedNumberFrames decoded.
packetsLostNumberPackets lost.
packetsReceivedNumberPackets received.
codecStringCodec used to decode data.
fpsNumberFrames per second.
roundTripTimeNumberRound Trip Time of the webRTC connection.

Limit Bitrate

Limit the bitrate limit for the received stream. View example on Github

Parameters

PropertyTypeDescription
bitrateLimitInBitsPerSecondNumberBitrate limit of the stream.
JavaScript
1var bitrateLimitInBitsPerSecond = 500000;
2
3 channel.setBitrateLimit(bitrateLimitInBitsPerSecond);

Clear Bitrate Limit

Clear bitrate limit that was prior set. View example on Github

JavaScript
1channel.clearBitrateLimit();
Page Content
    Copyright 2023 © Phenix RTS
    Privacy Policy | Terms of Service
    v2023-01-31T21:25:10