new KRtcCilent(paramters)
KEDACOM WEBRTC SDK
Parameters:
| Name | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
paramters |
object | 参数对象 Properties
|
- Source:
Example
// 示例1:
let krtcCilent = new KRtcCilent();
// 示例2:
let krtcCilent = new KRtcCilent({
clientId: "CLIENT12345678"
});
Methods
-
accept(paramters) → {object}
-
接受被呼
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description roomIdstring 会议E164
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
Example
// 示例: krtcClient.accept({ roomId: "6660001", success: function(data) { console.log("入会成功"); }, error: function(data) { console.log("入会失败"); } }); -
autoLogin(paramters) → {object}
-
免登录用户登录
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Description roomIdstring 会议e164
nicknamestring 免登录用户昵称
hostnamestring 服务的地址或域名
portstring 端口
autoPubLocalStreamboolean 是否自动发布本机音视频流
autoSubAllVideoStreamboolean 自动订阅所有视频流
successfunction 成功回调
errorfunction 失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
-
changeCamera(paramters) → {object}
-
切换摄像头
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description deviceIdstring 扬声器设备id,优先于facingMode
widthnumber 视频宽度
heightnumber 视频高度
facingModestring 移动设备的前后置摄像头:environment-后置摄像头,user-前置摄像头
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
-
changeLoudspeaker(paramters) → {object}
-
切换扬声器
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description deviceIdstring 扬声器设备id
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
-
changeMicrophone(paramters) → {object}
-
切换麦克风
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description deviceIdstring 设备id
autoGainControlstring <optional>
麦克风增益:true-开启麦克风增益,false-关闭麦克风增益,缺省默认为false
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
Example
// 示例: krtcClient.changeMicrophone({ deviceId: "MICROPHONE12345678", autoGainControl: true }); -
destroy()
-
销毁sdk
- Source:
-
disableCamera(paramters) → {object}
-
关闭摄像头
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description isTestboolean 是否测试模式:true-是,false-否
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
-
disableLoudspeaker(paramters) → {object}
-
关闭扬声器
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
-
disableMicrophone(paramters) → {object}
-
关闭麦克风
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
Example
// 示例: krtcClient.disableMicrophone();
-
disableShare(paramters) → {object}
-
关闭屏幕共享
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
-
enableCamera(paramters) → {object}
-
开启摄像头
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description deviceIdstring 扬声器设备id,优先于facingMode
widthnumber 视频宽度
heightnumber 视频高度
definitionnumber 分辨率,值为360P,720P
facingModestring 移动设备的前后置摄像头:environment-后置摄像头,user-前置摄像头
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
-
enableLoudspeaker(paramters) → {object}
-
开启扬声器
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description deviceIdstring 扬声器设备id
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
-
enableMicrophone(paramters) → {object}
-
开启麦克风
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description deviceIdstring 设备id
autoGainControlstring <optional>
麦克风增益:true-开启麦克风增益,false-关闭麦克风增益,缺省默认为false
successfunction <optional>
成功回调,参数:{ audioTrack: audioTrack }
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
Example
// 示例: krtcClient.enableMicrophone({ deviceId: "MICROPHONE12345678", autoGainControl: true }); -
enableShare(paramters) → {object}
-
开启屏幕共享
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description widthnumber 视频宽度
heightnumber 视频高度
frameRatenumber 视频最大帧率
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
-
exit(paramters) → {object}
-
离开会议
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description reasonstring <optional>
离会原因
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
Example
// 示例: krtcClient.exit({ reason: "正常离会" }); -
getCurrentCamera() → {string}
-
获取当前使用的摄像头
- Source:
Returns:
字符串
- Type
- string
-
getCurrentLoudspeaker() → {string}
-
获取当前使用的扬声器
- Source:
Returns:
字符串
- Type
- string
-
getCurrentMicrophone() → {string}
-
获取当前使用的麦克风
- Source:
Returns:
字符串
- Type
- string
-
getNickname() → {String}
-
获取当前用户昵称
- Source:
Returns:
nickName - 当前用户昵称,字符串,eg:"游客9527"
- Type
- String
Example
// 示例: let nickname = krtcCilent.getNickname();
-
getRoomId() → {String}
-
获取当前的会议号码,如果还没入会,则返回空字符串
- Source:
Returns:
roomId - 当前的会议号码,字符串,eg:"6660001"
- Type
- String
Example
// 示例: let roomId = krtcCilent.getRoomId();
-
getRoomInfo() → {Json}
-
获取当前的会议详情,如果还没入会,则返回空对象
- Source:
Returns:
roomInfo - 当前所处会议的详情
- Type
- Json
-
getStatsInfo() → {JSON}
-
获取订阅/发布流信息
- Source:
Returns:
主流音视频发布订阅,双流发布订阅信息
- Type
- JSON
-
getUserId() → {string}
-
实例方法 获取当前SDK实例登录的用户ID
- Source:
Returns:
字符串,eg:"1234560000000"
- Type
- string
Example
// 示例: let userId = krtcCilent.getUserId();
-
getUserList() → {Array}
-
获取当前的会议的终端列表,如果还没入会,则返回空数组
- Source:
Returns:
Array
当前会议的终端列表 - Type
- Array
-
getVersion() → {string}
-
实例方法 获取当前SDK的版本号
- Source:
Returns:
当前sdk的版本号,例如:V6.1.0.4.0.20210518202928
- Type
- string
Example
// 示例: krtcClient.getVersion();
-
init(paramters) → {object}
-
初始化SDK
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description debugstring <optional>
是否在浏览器控制台输出调试日志
hostnamestring 服务的地址或域名
portstring <optional>
端口,默认443标准端口
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
Example
// 示例: krtcClient.init({ hostname: "172.16.186.220", success: function(data) { console.log("初始化成功"); }, error: function(data) { console.log("初始化失败"); } }); -
join(paramters) → {object}
-
加入会议
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description roomIdstring 会议E164
passwordstring <optional>
密码
onAudioReceivedstring <optional>
接收到声音的回调处理,参数:{ audioTrack: audioTrack }
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
Example
// 示例: krtcClient.join({ roomId: "6660001", password: "", success: function(data) { console.log("入会成功"); }, error: function(data) { console.log("入会失败"); } }); -
listCamera(paramters) → {Object}
-
获取摄像头列表
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description keywordstring <optional>
搜索关键字
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
-
model - 返回结果
- Type
- Object
-
model.success 调用是否成功
- Type
- boolean
-
model.data 设备列表
- Type
- Array
Example
// 示例: krtcClient.listCamera({ keyword: "" }); -
listLoudspeaker(paramters) → {DeviceInfoModel}
-
获取扬声器列表
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description keywordstring <optional>
搜索关键字
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
扬声器列表 (JSON) 自定义对象
- Type
- DeviceInfoModel
Example
// 示例: krtcClient.listLoudspeaker({ keyword: "" }); -
listMicrophone(paramters) → {DeviceInfoModel}
-
获取麦克风列表
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description keywordstring <optional>
搜索关键字
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
DeviceInfoModel - Json 自定义对象
- Type
- DeviceInfoModel
Example
// 示例: krtcClient.listMicrophone({ keyword: "" }); -
login(paramters) → {object}
-
登录
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description userIdstring <optional>
用户名ID,可选参数,若不传入或为空时分配免登陆账号
nicknamestring 用户昵称
appTokenstring 应用token
autoPubLocalStreamboolean 是否自动发布本机音视频流
autoSubAllVideoStreamboolean 自动订阅所有视频流
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
SkyClient 实例
- Type
- object
Example
// 示例1:使用用户Id为 1234560000000,登录 krtcClient.login({ userId: "1234560000000", nickname: "172.16.186.220", appToken: "TOKEN12345678" }); // 示例2:使用系统分配账号登录 krtcClient.login({ nickname: "172.16.186.220", appToken: "TOKEN12345678", success: function(data) { console.log("登录成功"); }, error: function(data) { console.log("登录失败"); } }); -
reject(paramters) → {object}
-
拒绝被呼
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description roomIdstring 会议E164
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
Example
// 示例: krtcClient.reject({ roomId: "6660001", success: function(data) { console.log("拒绝成功"); }, error: function(data) { console.log("拒绝失败"); } }); -
stopTestLoudspeaker(paramters) → {object}
-
停止测试扬声器
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description deviceIdstring 扬声器设备id
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
-
subscribe(paramters) → {object}
-
终端订阅(如果已订阅会直接返回,不做处理)
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description userIdstring 终端id,终端列表返回的终端 编号信息,订阅辅流时可不传
mediaTypestring 码流标识:'audio'-订阅音频(暂不支持),'video'-订阅主流视频,'dualvideo'-订阅辅流视频
qualitystring 视频流分层标识: low-低分辨率层、middle-中分辨率层、high-高分辨率层
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
Example
// 示例1:订阅用户ID为 6660001 的主流视频低分辨率 krtcClient.subscribe({ userId: "6660001", mediaType: "video", quality: "low" }); // 示例2:订阅辅流视频高分辨率 krtcClient.subscribe({ mediaType: "dualvideo", quality: "high" }); -
subscribeChange(paramters) → {object}
-
终端订阅改变(如果已订阅会直接返回,不做处理)
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description userIdstring 终端id,终端列表返回的终端 编号信息,订阅辅流时可不传
mediaTypestring 码流标识:'audio'-订阅音频(暂不支持),'video'-订阅主流视频,'dualvideo'-订阅辅流视频
qualitystring 视频流分层标识: low-低分辨率层、middle-中分辨率层、high-高分辨率层
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
Example
// 示例1:改变订阅用户ID为 6660001 的主流视频低分辨率 krtcClient.subscribeChange({ userId: "6660001", mediaType: "video", quality: "low" }); // 示例2:改变订阅辅流视频高分辨率 krtcClient.subscribeChange({ mediaType: "dualvideo", quality: "high" }); -
testLoudspeaker(paramters) → {object}
-
开始测试扬声器
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description playstatusboolean 当前是否正在播放,true-正在播放,false-未播放
deviceIdstring 扬声器设备id
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
-
testLoudspeakerVolume() → {string}
-
获取扬声器测试音量
- Source:
Returns:
扬声器音量值
- Type
- string
-
testMicrophone() → {JSON}
-
测试麦克风
- Source:
Returns:
abandon
- Type
- JSON
-
testMicrophoneVolume(paramters) → {number}
-
获取麦克风测试音量
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
麦克风音量值
- Type
- number
Example
// 示例:可定时获取测试音量用于显示麦克风的能量值 let volume = krtcClient.testMicrophoneVolume();
-
unsubscribe(paramters) → {object}
-
终端取消订阅(如果已订阅会直接返回,不做处理)
Parameters:
Name Type Description paramtersobject 参数对象
Properties
Name Type Argument Description userIdstring 终端id,终端列表返回的终端 编号信息,订阅辅流时可不传
mediaTypestring 码流标识:'audio'-音频(暂不支持),'video'-主流视频,'dualvideo'-辅流视频
successfunction <optional>
成功回调
errorfunction <optional>
失败回调
- Source:
Returns:
KRtcCilent 实例
- Type
- object
Example
// 示例1:取消订阅用户ID为 6660001 的主流视频低分辨率 krtcClient.unsubscribe({ userId: "6660001", mediaType: "video", quality: "low" }); // 示例2:取消订阅辅流视频高分辨率 krtcClient.unsubscribe({ mediaType: "dualvideo", quality: "high" });
KRTC Web SDK