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类型默认值必填说明最低版本
channelIdstringStringyes通话频道
在同一个频道内的用户可以互相通话,多个用户加入同一个频道
1.0.0
uidnumberintno用户id1.0.0


方法:

方法名参数JS类型Java类型必填参数说明方法说明最低版本
createappIdstringStringyesAgora 为 app 开发者签发的 App ID
使用同一个 App ID 的 app 才能进入同一个频道进行通话或直播。
创建 RtcEngine 实例
目前只支持每个 app 创建一个 RtcEngine 实例
1.0.0
enableVideo启用视频模块1.0.0
enableAudio启用音频模块1.0.0
setVideoEncoderConfigurationconfigVideoEncoderConfigurationMapyes视频编码属性,详细定义见 VideoEncoderConfiguration设置视频编码配置1.0.0
setChannelProfileprofileChannelProfileintyes0 ChannelProfile.Communication(默认)
1 ChannelProfile.LiveBroadcasting
2 ChannelProfile.Game
设置频道场景1.0.0
joinChanneltokenstringStringyesApp 服务器端生成的用于鉴权的 Token加入频道1.0.0
channelNamestringStringyes标识通话的频道名称,长度在 64 字节以内的字符串
optionalInfostringStringno开发者需加入的任何附加信息
optionalUidnumberintno用户 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>
);
}