...
Code Block | ||
---|---|---|
| ||
// Generate new Token
LIVECHATSDK.LIVECHAT.getVideoToken(AD_VIDEO_Obj.chat_id, "AGENT").then(
function (data) {
var TokenID = data.token;
console.log("[VIDYO] Token [" + TokenID + "]" );
// Create a Video Connector
VC.CreateVidyoConnector(
{
viewId: "divPanelVideo", // DOM element reserved to video render
viewStyle: "VIDYO_CONNECTORVIEWSTYLE_Default",
remoteParticipants: 2, // Max number of participants
logFileFilter: "info", // Log levels
logFileName: "",
userData: ""
}
).then(
function(vidyoConnector) {
// Connect to Video Room
vidyoConnector.Connect(
{
host: "prod.vidyo.io",
token: TokenID, //Generated Token
displayName: "CUSTOMER",
resourceId: "CHAT_DEFAULT_e9f75bfb-b8cc-4141-8c74-646d45636a14", // Video Conference Name, use the CTLive CHAT ID
onSuccess: function () {
console.log("[VIDYO] CONNECTED");
vidyoConnector.RegisterParticipantEventListener(
{
onJoined: VIDYO_onJoined,
onLeft: VIDYO_onLeft,
onDynamicChanged: VIDYO_onDynamicChanged,
onLoudestChanged: VIDYO_onLoudestChanged
}
);
console.log("[VIDYO] SELECT DEFAULT CAMERA");
vidyoConnector.SelectDefaultCamera();
console.log("[VIDYO] SELECT DEFAULT MICROPHONE");
vidyoConnector.SelectDefaultMicrophone();
console.log("[VIDYO] SELECT DEFAULT SPEAKERS");
vidyoConnector.SelectDefaultSpeaker();
},
onFailure: function (reason) {
console.log("[VIDYO] CONNECT ERROR [" + reason + "]");
},
onDisconnected: function (reason) {
console.log("[VIDYO] DISCONNECTED [" + reason + "]");
console.log("[VIDYO] Call Disconnect() API on Video Connector");
vidyoConnector.Disconnect().then(
function (result) {
console.log("[VIDYO] Call Disable() API on Video Connector");
vidyoConnector.Disable();
}
);
}
}
).catch( function (err) {console.err(err); }
);
}
);
}
).catch( function(err) { console.err(err); } );
|
...