startPreview method
开启预览
channelNum 可切换通道
streamType 可切换码流
level 层级, 通设备 同通道 同码流, 在不同页面层级, 需创建新的EventChannel.
Implementation
Future<int> startPreview(
{int? channelNum, int? streamType, int level = 0}) async {
if (channelNum != null) {
this.channelNum = channelNum;
}
if (streamType != null) {
this.streamType = streamType;
}
this.level = level;
_createMessage();
_createMethodChannel();
if (Platform.isIOS) {
if (!_platformViewCreatedCompleter.isCompleted) {
await _platformViewCreatedCompleter.future;
}
} else {
//Android不需要等待
if (!_platformViewCreatedCompleter.isCompleted) {
_platformViewCreatedCompleter.complete();
}
}
if (_disposed) {
return -1;
}
_createdSurface = await _mediaPlayer.create(msg: createMessage);
_onCreate();
return _playHandle;
}