LVCEngine JS SDK API 文档
更新时间:2020-06-03
LVCEngine
创建LVCEngine实例
new LVCEngine(userId, imAppId, rtcAppId, appKey, socketUrl, env, appPackageName, type)
Param | Type | Default | Description |
---|---|---|---|
userId | string | 用户的userId | |
imAppId | string | im appId | |
rtcAppId | string | rtc appId | |
appKey | string | im appKey | |
socketUrl | string | socketUrl | |
socketUrl | string | socketUrl | |
appPackageName | string | 包名 | |
env | string | "prod" | "test" | SDK环境选择 |
[type] | string | "international" | "china" | 节点环境选择 |
登录房间
LVCEngine.joinRoom(userId, roomId, role, token, auth, expire) ⇒ Array
| errMsg
Kind: instance method of LVCEngine
Returns: Array
| errMsg
- {(Promise<streamList[] | errMsg>)}
Param | Type | Description |
---|---|---|
userId | string | 用户id |
roomId | string | 房间id |
role | 1 | 2 | 角色 |
token | string | 鉴权token |
auth | string | 鉴权签名值 |
expire | string | 过期时间戳 |
登出房间
LVCEngine.logout() ⇒ void
Kind: instance method of LVCEngine
Returns: void
RTC部分
创建流
LVCEngine.createStream([source]) ⇒ mediastream
Kind: instance method of LVCEngine
Returns: mediastream
- {Promise
Param | Type | Description |
---|---|---|
[source] | object | 视频源类型 |
[source.camera] | object | 摄像头 |
[source.screen] | object | 屏幕共享 |
[source.custom] | object | 自定义流 |
[source.camera.audio] | boolean | 是否开启音频 |
[source.camera.video] | boolean | 是否开启视频 |
[source.camera.audioInput] | string | 音频输入设备 |
[source.camera.audioBitrate] | number | 音频码率 |
[source.camera.videoInput] | string | 视频输入设备 |
[source.camera.videoQuality] | 1 | 2 | 3 | 4 | 视频质量 |
[source.camera.facingMode] | string | 切换摄像头(移动端) |
[source.camera.width] | number | 宽 |
[source.camera.height] | number | 高 |
[source.camera.frameRate] | number | 帧率 |
[source.camera.bitrate] | number | 码率 |
[source.camera.AGC] | boolean | 自动增益 |
[source.camera.ANS] | boolean | 回声消除 |
[source.camera.AEC] | boolean | 降噪 |
[source.screen.audio] | boolean | (共享屏幕)是否开启音频 |
[source.screen.videoQuality] | 1 | 2 | 3 | 4 | 视频质量设置 |
[source.screen.frameRate] | number | 帧率 |
[source.screen.bitrate] | number | 码率 |
source.custom.source | MediaStream | 视频流 |
[source.custom.bitrate] | number | 码率 |
删除流
LVCEngine.destroyStream(mediastream)
Kind: instance method of LVCEngine
Param | Type |
---|---|
mediastream | MediaStream |
开始推流
LVCEngine.startPublishingStream(streamId, mediaElement) ⇒ void
Kind: instance method of LVCEngine
Returns: void
- {Promise
Param | Type | Description |
---|---|---|
streamId | string | 流id |
mediaElement | MediaStream | 流 |
停止推流
LVCEngine.stopPublishingStream(streamId)
Kind: instance method of LVCEngine
Param | Type | Description |
---|---|---|
streamId | string | 流id |
开始拉流
LVCEngine.startPlayingStream(streamId) ⇒ void
Kind: instance method of LVCEngine
Returns: void
- {(Promise<MediaStream | void>)}
Param | Type | Description |
---|---|---|
streamId | string | 流id |
停止拉流
LVCEngine.stopPlayingStream(streamId)
Kind: instance method of LVCEngine
Param | Type | Description |
---|---|---|
streamId | string | 流id |
开启静音
LVCEngine.muteSwitch(streamId, mute)
Kind: instance method of LVCEngine
Param | Type | Description |
---|---|---|
streamId | string | 流id |
mute | boolean | 是否静音 |
切换摄像头
LVCEngine.cameraSwitch(streamId, state)
Kind: instance method of LVCEngine
Param | Type | Description |
---|---|---|
streamId | string | 流id |
state | 'close' | 'open' | 摄像头状态 |
流变化通知 event
"stream-update" ⇒ stramUpdateResult
Kind: event emitted by LVCEngine
Since: 2.0
websocket 断开通知 event.
"disconnect" ⇒ errMsg
Kind: event emitted by LVCEngine
Since: 2.0
踢人通知 event.
"kick-out" ⇒ kickResult
Kind: event emitted by LVCEngine
Since: 2.0
推流状态通知 event.
"publish-state-update" ⇒ streamStateResult
Kind: event emitted by LVCEngine
Since: 2.0
拉流状态通知 event.
"play-state-update" ⇒ streamStateResult
Kind: event emitted by LVCEngine
Since: 2.0
自定义类型
- errMsg :
Object
- sourceCamera :
Object
- videoQuality :
1
|2
|3
|4
- stramUpdateResult
- kickResult
- streamStateResult
Object
errMsg : Kind: global typedef
Properties
Name | Type |
---|---|
code | number |
msg | string |
Object
sourceCamera : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
audio | boolean | 是否开启音频 |
video | boolean | 是否开启视频 |
audioInput | string | 音频输入设备 |
videoInput | string | 视频输入设备 |
videoQuality | number | 视频质量 |
facingMode | string | 摄像头朝向,"user"表示前置摄像头,"environment"表示后置摄像头 |
width | number | 宽 |
height | number | 高 |
frameRate | number | 帧率 |
bitrate | number | 码率 |
AGC | boolean | 自动增益 |
ANS | boolean | 回声消除 |
AEC | boolean | 降噪 |
1
| 2
| 3
| 4
videoQuality : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
1 | number | 分辨率: 320 * 240, 帧率: 15, 码率: 300 |
2 | number | 分辨率: 640 * 480, 帧率: 15, 码率: 800 |
3 | number | 分辨率: 1280 * 720, 帧率: 20, 码率: 1500 |
4 | number | 分辨率: width * height, 帧率: frameRate, 码率: bitRate(k) |
stramUpdateResult
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
code | number | 标识码 1 为增加 0为减少 |
streamList | [ 'Array' ].<{streamId: string, userId: string, roomId: string}> | 流列表 |
kickResult
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
userId | string | 用户Id |
roomId | string | 房间Id |
reason | number | 错误码 |
streamStateResult
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
code | number | 错误码 |
state | string | 当前状态 |
reason | string | 原因 |
直播间部分
LVCEngine.liveroomManager Kind: global class
- LiveroomManager
- new LiveroomManager()
- instance
- .create(roomId) ⇒
void
- .join(roomId) ⇒
void
- .leave(roomId) ⇒
void
- .mute(roomId, userId) ⇒
void
- .unmute(roomId, userId) ⇒
void
- .muteAll(roomId) ⇒
void
- .unmuteAll(roomId) ⇒
void
- .sendMessage(roomId, content) ⇒
void
- .create(roomId) ⇒
- static
创建房间
liveroomManager.create(roomId) ⇒ void
Kind: instance method of LiveroomManager
Returns: void
- {Promise\<void>}
Param | Type | Description |
---|---|---|
roomId | string | 房间ID |
加入房间
liveroomManager.join(roomId) ⇒ void
Kind: instance method of LiveroomManager
Returns: void
- {Promise\<void>}
Param | Type | Description |
---|---|---|
roomId | string | 房间ID |
离开房间
liveroomManager.leave(roomId) ⇒ void
Kind: instance method of LiveroomManager
Returns: void
- {Promise\<void>}
Param | Type | Description |
---|---|---|
roomId | string | 房间ID |
用户静音
liveroomManager.mute(roomId, userId) ⇒ void
Kind: instance method of LiveroomManager
Returns: void
- {Promise\<void>}
Param | Type | Description |
---|---|---|
roomId | string | 房间ID |
userId | string | 用户ID |
用户取消静音
liveroomManager.unmute(roomId, userId) ⇒ void
Kind: instance method of LiveroomManager
Returns: void
- {Promise\<void>}
Param | Type | Description |
---|---|---|
roomId | string | 房间ID |
userId | string | 用户ID |
房间静音
liveroomManager.muteAll(roomId) ⇒ void
Kind: instance method of LiveroomManager
Returns: void
- {Promise\<void>}
Param | Type | Description |
---|---|---|
roomId | string | 房间ID |
房间取消静音
liveroomManager.unmuteAll(roomId) ⇒ void
Kind: instance method of LiveroomManager
Returns: void
- {Promise\<void>}
Param | Type | Description |
---|---|---|
roomId | string | 房间ID |
发送直播间消息
liveroomManager.sendMessage(roomId, content) ⇒ void
Kind: instance method of LiveroomManager
Returns: void
- {Promise\<void>}
Param | Type | Description |
---|---|---|
roomId | string | 房间ID |
content | string | 消息内容 |
获取创建直播间消息 event
"create" ⇒ object
Kind: event emitted by LiveroomManager
Returns: object
- {{roomId: string, userId: string}}
获取加入直播间消息 event
"join" ⇒ object
Kind: event emitted by LiveroomManager
Returns: object
- {{roomId: string, userId: string}}
获取离开直播间消息 event
"leave" ⇒ object
Kind: event emitted by LiveroomManager
Returns: object
- {{roomId: string, userId: string}}
获取直播间实时消息 event
"message" ⇒ object
Kind: event emitted by LiveroomManager
Returns: object
- {{from: string, to: string, content: string}}
私信部分
LVCEngine.personalManager Kind: global class
- PersonalManager
- new PersonalManager()
- instance
- .sendMessage(userId, content) ⇒
void
- .sendAck(received) ⇒
void
- .sendMessage(userId, content) ⇒
- static
- "message" ⇒
object
- "message" ⇒
发送私信
personalManager.sendMessage(userId, content) ⇒ void
Kind: instance method of PersonalManager
Returns: void
- {Promise\<void>}
Param | Type | Description |
---|---|---|
userId | string | 用户ID |
content | string | 消息内容 |
发送接收反馈
personalManager.sendAck(received) ⇒ void
Kind: instance method of PersonalManager
Returns: void
- {Promise\<void>}
Param | Type |
---|---|
received | Array.<TextMsgDataWrapper> |
获取私信消息 event
"message" ⇒ object
Kind: event emitted by PersonalManager
Returns: object
- {{from: string, to: string, content: string}}
获取未读消息列表
pullManager.getUnreadMessageList([sequenceId], [totalSize]) ⇒ object
Kind: instance method of PullManager
Returns: object
- {Promise<[type: string, message: string]>}
Param | Type | Default |
---|---|---|
[sequenceId] | number | Long | 0 |
[totalSize] | number | -1 |
获取错误消息 event
"error" ⇒ object
Kind: event emitted
Returns: object
- {type: number, data: any, error: string}