1.24.2 • Published 4 years ago
@efox/webrtc v1.24.2
Install
npm
npm i --save-dev @efox/webrtc
yarn
yarn add -s @efox/webrtc
Use it in your project
import { RtcService } from '@efox/webrtc'
APIs
RtcService
Function | Summary | Useage | Paramter | ReturnType | |
---|---|---|---|---|---|
initWebRtc | 根据参数初始化实例,并根据refs中的uid自动填装绑定video标签 | initWebRtc(param) | param: initParam | Promise | |
startLiveAndJoinRoom | 开播并创建房间 | startLiveAndJoinRoom(param) | param: startLiveParam | Promise | |
joinRoom | 加入房间 | joinRoom(uid, roomid) | uid: string, roomid: string | Promise | |
showVideo | 将流填充入对应el中 | showVideo(el, MediaStreamId) | el: HTMLVideoElement, MediaStreamId: string | void | |
publishVideo | 根据type发布视频 | publishVideo(type, param) | type: 'screen'or'camera', param: publishParam | Promise | |
unpublishVideo | 取消发布 | unpublishVideo(type) | type: 'screen'or'camera' | Promise | |
enableVideo | 打开视频采集 | enableVideo(type) | type: 'screen'or'camera' | void | |
disableVideo | 关闭视频采集 | disableVideo(type) | type: 'screen'or'camera' | void | |
enableAudio | 打开音频采集 | enableAudio(type) | type: 'screen'or'camera' | void | |
disableAudio | 关闭音频采集 | disableAudio(type) | type: 'screen'or'camera' | void | |
getVideoDevice | 获取视频设备 | getVideoDevice(fn) | fn:Function(deviceInfo?: {deviceId: string}) | void | |
getAudioDevice | 获取音频设备 | getAudioDevice(fn) | fn:Function(deviceInfo?: {deviceId: string}) | void | |
setPublisherVolume | 设置麦克风音量 | setPublisherVolume(type, volume) | type: 'screen' | 'camera', volume: 0-100 | void |
changeRoom | 更换房间 | changeRoom(uid) | uid: string | Promise | |
addRefs | 添加展示流的标签 | addRefs(refs) | refs: videoRefs[] | void | |
addBaseInfo | 添加基本信息 | addBaseInfo(param) | param: baseInfo | void | |
onLiveRoomInfoChange | 房间信息更改监听 | onLiveRoomInfoChange(fn) | fn: (data?: liveRoomInfo) => void | void | |
offLiveRoomInfoChange | 取消监听 | offLiveRoomInfoChange(fn) | fn: (data?: liveroomInfo) => void | void | |
leaveRoom | 离开房间 | leaveRoom() | null | Promise |