startVideoStreaming method
Start a video streaming to the url in url`
.
This uses rtmp to do the sending the remote side.
Throws a CameraException if the capture fails.
Implementation
Future<void> startVideoStreaming(String url,
{int bitrate = 1200 * 1024, bool? androidUseOpenGL}) async {
if (!value.isInitialized! || _isDisposed) {
throw CameraException(
'Uninitialized CameraController',
'startVideoStreaming was called on uninitialized CameraController',
);
}
if (value.isRecordingVideo!) {
throw CameraException(
'A video recording is already started.',
'startVideoStreaming was called when a recording is already started.',
);
}
if (value.isStreamingVideoRtmp!) {
throw CameraException(
'A video streaming is already started.',
'startVideoStreaming was called when a recording is already started.',
);
}
if (value.isStreamingImages!) {
throw CameraException(
'A camera has started streaming images.',
'startVideoStreaming was called while a camera was streaming images.',
);
}
try {
await _channel
.invokeMethod<void>('startVideoStreaming', <String, dynamic>{
'textureId': _textureId,
'url': url,
'bitrate': bitrate,
});
value =
value.copyWith(isStreamingVideoRtmp: true, isStreamingPaused: false);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
}