orionos-extension-agora
最后更新: 2020/7/17组件功能:
orionos-extension-agora 用于支持声网sdk
Agora SDK官方文档链接:https://docs.agora.io/cn/Video/API%20Reference/java/index.html
Agora SDK版本:3.0.1.1
注意事项:
安装方式: npm install orionos-extension-agora
安装完成后,将在工程目录下的 extraResource/ 中生成libs 目录;
libs目录是 debug 和 生成opk 的必要文件,请勿随意操作该目录。
支持平台:
平台 | 是否支持 |
豹小秘 | 否 |
豹花/大瓶 | 否 |
M平台 | 是 |
更新日志
版本号 | 更新内容 |
1.0.0 | 声网sdk组件第一版 |
参数
属性 | JS 类型 | Java类型 | 默认值 | 必填 | 说明 | 最低版本 |
channelId | string | String | 无 | yes | 通话频道 在同一个频道内的用户可以互相通话,多个用户加入同一个频道 | 1.0.0 |
uid | number | int | 无 | no | 用户id | 1.0.0 |
方法:
方法名 | 参数 | JS类型 | Java类型 | 必填 | 参数说明 | 方法说明 | 最低版本 |
create | appId | string | String | yes | Agora 为 app 开发者签发的 App ID 使用同一个 App ID 的 app 才能进入同一个频道进行通话或直播。 | 创建 RtcEngine 实例 目前只支持每个 app 创建一个 RtcEngine 实例 | 1.0.0 |
enableVideo | 无 | 无 | 无 | 无 | 无 | 启用视频模块 | 1.0.0 |
enableAudio | 无 | 无 | 无 | 无 | 无 | 启用音频模块 | 1.0.0 |
setVideoEncoderConfiguration | config | VideoEncoderConfiguration | Map | yes | 视频编码属性,详细定义见 VideoEncoderConfiguration | 设置视频编码配置 | 1.0.0 |
setChannelProfile | profile | ChannelProfile | int | yes | 0 ChannelProfile.Communication(默认) 1 ChannelProfile.LiveBroadcasting 2 ChannelProfile.Game | 设置频道场景 | 1.0.0 |
joinChannel | token | string | String | yes | App 服务器端生成的用于鉴权的 Token | 加入频道 | 1.0.0 |
channelName | string | String | yes | 标识通话的频道名称,长度在 64 字节以内的字符串 | |||
optionalInfo | string | String | no | 开发者需加入的任何附加信息 | |||
optionalUid | number | int | no | 用户 ID,32 位无符号整数 建议设置范围:1 到 (2^32-1),并保证唯一性。 |
示例代码:
import RtcEngine, { LocalView } from 'orionos-extension-agora';
private engine: RtcEngine;
public constructor(props) {
super(props)
RtcEngine.create('your appId');
this.engine = new RtcEngine();
this.engine.enableVideo();
this.engine.enableAudio();
let videoDimens = new VideoDimensions(640, 360);
let config = new VideoEncoderConfiguration({dimensions: videoDimens, frameRate: VideoFrameRate.Fps15, bitrate: 300});
this.engine.setVideoEncoderConfiguration(config);
this.engine.setChannelProfile(ChannelProfile.Communication);
}
public componentDidMount() {
this.engine.joinChannel(null, 'channelxxxxxxxxx', null, 100000000);
}
public render() {
return (
<View style={{flex: 1, backgroundColor: 'blue'}}>
<LocalView.SurfaceView
channelId={'channelxxxxxxxxx'}
style={{width: 640, height: 360}}
/>
{/* <RtcLocalView.TextureView
style={{width: 640, height: 360}}
/> */}
</View>
);
}