【发布时间】:2021-12-16 11:03:56
【问题描述】:
我正在使用 Flutter Agora SDK 开发语音通话应用程序。到目前为止,我已经能够舒适地进行语音通话而没有任何错误。但是今天,在我的真实设备上测试它时,即使我没有对初始化过程进行任何更改,它也会出错。奇怪的是,它在模拟器上没有任何错误,但只有在真实设备上才会出错。
Future<void> initAgora() async {
await [Permission.microphone].request();
try {
engine = await RtcEngine.createWithContext(RtcEngineContext(APP_ID));
await engine.enableAudio();
await engine.setChannelProfile(ChannelProfile.Communication);
engine.setEventHandler(
RtcEngineEventHandler(
activeSpeaker: (i) {
log("Active Speaker: $i");
},
microphoneEnabled: (enable) {
log("Microphone: " + enable.toString());
callingController.microphoneState.value = enable;
},
warning: (warningCode) {
print(warningCode.toString());
},
rtcStats: (stats) {
log("User Count: ${stats.userCount}");
},
connectionStateChanged: (state, reason) {
log("Connection Changed : ${state.toString()}, ${reason.toString()}");
},
joinChannelSuccess: (String channel, int uid, int elapsed) {
log('joinChannelSuccess $channel $uid');
},
userJoined: (int uid, int elapsed) {
log('userJoined $uid');
},
userOffline: (int uid, UserOfflineReason reason) {
log('userOffline $uid');
callingController.finishCall(uid, "user_left");
},
error: (error) {
log("ERROR: $error", name: "AGORA");
},
),
);
if (callingController.isCallerMe) {
await joinChannel();
}
} catch (e) {
print(e);
failureSnackbar(e.toString());
}
}
【问题讨论】:
-
您使用的是什么真实设备?什么时候抛出这个异常?
-
我的真机是小米9T Pro。
await engine.setChannelProfile()工作时抛出的线。