Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace JuphoonRTCConference

Index

Functions

createConferenceClient

  • createConferenceClient(appKey: string, token: string, socketAddress?: string): RTCConference
  • 创建多方client

    第三个参数 socketAddress 如果使用 setConfig 接口设置过地址, 可不传.

    Parameters

    • appKey: string

      appKey

    • token: string

      token

    • Optional socketAddress: string

      WebSocket的连接地址

    Returns RTCConference

detect

  • detect(requestUser?: boolean, detectNetwork?: boolean): Promise<RTCSupportInfo>
  • 检测浏览器环境的支持程度

    进行检测时如果参数传了 true , 则会去向用户请求媒体设备的权限, 用户允许后能够得到设备的 deviceId 可以通过 deviceId 进行切换设备等操作.

    JuphoonRTCConference.setConfig({
     appKey: appKeyInput.value,
     address: 'http(s)://IP:PORT',
    });
    
    // getToken接口仅demo演示使用, 实际集成时应从第三方接口获取.
    JuphoonRTCConference.getToken()
     .then(_token => {
       JuphoonRTCConference.setConfig({token: _token});
       //  如需要检测网络状态请提前设置至少 `appKey`, `token`, `address` 三个参数
       JuphoonRTCConference.detect(true, true)
         .then(info => {
           console.log(info);
         })
         .catch(reason => {
           console.error(reason);
         });
     })
     .catch(reason => {
       alert('获取token失败,确认地址已信任');
       alert(reason);
     });
    
    version

    2.4.10 增加 detectNetwork , 用于开启WebRTC网络状态检测

    Parameters

    • requestUser: boolean = true

      是否请求用户的媒体设备, 请求媒体设备能够得到更加完整的兼容信息

    • detectNetwork: boolean = false

      是否检测网络环境, 开启检测将提前向服务发起连接, 并且在此之前需要通过setConfig至少设置 appKey, token, address 三个参数.

    Returns Promise<RTCSupportInfo>

getMediaDevices

  • 获取设备媒体信息

    将返回 _WebDevicesInfo 的唯一实例, 建议先调用 detect 接口, detect 默认情况下会使用默认的选项向用户发起媒体设备(如: 摄像头, 麦克风)授权请求, 并将获取到的音视频轨道保存在内存中, 除非使用不同的选项(StreamCameraConstraints, StreamMicrophoneConstraints)请求媒体设备, 否则都不用再次结果用户授权.

    获取到的媒体设备信息可用来进行切换摄像头等操作.

    const  client = JuphoonRTCConference.createConferenceClient('appKey', 'token'),
           //  第几个摄像头设备
           index = 0;
    
    JuphoonRTCConference.detect()
     .then(info => {
       if (!info.baseSupport) return;
    
       JuphoonRTCConference.getMediaDevices
         .then((devicesInfo) => {
           client.switchCamera({
             deviceId: devicesInfo.videoInputList[index].deviceId
           })
             .then(() => {
               console.log('设备切换成功')
             })
         })
     })
    

    Returns Promise<_WebDevicesInfo>

getVersion

  • getVersion(): any
  • 获取SDK版本信息

    Returns any

setConfig

  • setConfig(_config: SDKConfigDef & { nextVersion?: boolean }): void

Generated using TypeDoc