A platform view has been registered and is working when i use
AndroidVIew(viewType: 'OpenGLDisplayView')
But it doesn't work when i initiate an observer like this:
var handle = await engine.getNativeHandle();
await AgoraRtcRawdata.registerVideoFrameObserver(handle);
Here is configuration of PlatformView in .kt file:
mGLDisplayViewFactory = GLDisplayViewFactory(messenger)
binding.platformViewRegistry
.registerViewFactory("OpenGLDisplayView", mGLDisplayViewFactory)
NOTE: I am performing this configuration in a local package which i am accessing via path. Do i need to change my mainActivity.java ?
How to Actively use 'OpenGLDisplayView' as a custom video stream?
Packages are:
agora_rtc_rawdata: ^0.1.0
agora_rtc_engine: ^6.1.1`
when i use it in AgoraView the App Crashes`
_initEngine() async {
engine = createAgoraRtcEngine();
await engine.initialize(RtcEngineContext(
appId: config.appId,
channelProfile: ChannelProfileType.channelProfileLiveBroadcasting));
engine.registerEventHandler(RtcEngineEventHandler(
onJoinChannelSuccess: (RtcConnection connection, int elapsed) {
log('onJoinChannelSuccess connection: ${connection.toJson()} elapsed: $elapsed');
setState(() {
isJoined = true;
});
}, onUserJoined: (RtcConnection connection, int rUid, int elapsed) {
log('onUserJoined connection: ${connection.toJson()} remoteUid: $rUid elapsed: $elapsed');
setState(() {
remoteUid.add(rUid);
});
}, onUserOffline:
(RtcConnection connection, int rUid, UserOfflineReasonType reason) {
log('onUserOffline connection: ${connection.toJson()} remoteUid: $rUid reason: $reason');
setState(() {
remoteUid.remove(rUid);
});
}));
await engine.enableVideo();
await engine.startPreview();
setState(() {
startPreview = true;
});
await engine.joinChannel(
token: config.token,
channelId: config.channelId,
uid: 0,
options: ChannelMediaOptions());
var handle = await engine.getNativeHandle();
// await AgoraRtcRawdata.registerAudioFrameObserver(handle);
await AgoraRtcRawdata.registerVideoFrameObserver(handle);}
AgoraVideoView Code:
AgoraVideoView(
controller: VideoViewController(
rtcEngine: engine,
canvas: VideoCanvas(uid: 0),
),
),
Note the PlatformView works fine when i use it in AndroidView:
AndroidView(
viewType: 'OpenGLDisplayView'
),