setRotation method
Set the rotation of the output relative to the natural orientation of the device.
E.g. The natural orientation of a phone is typically portrait up.
Implementation
@override
Future<void> setRotation(OutputRotation rotation) {
verifyAttached();
final CameraInfo cameraInfo = _controller.device.info;
late final int videoRotation;
switch (rotation) {
case OutputRotation.rotation0:
videoRotation = cameraInfo.orientation;
break;
case OutputRotation.rotation90:
if (cameraInfo.facing == CameraInfo.cameraFacingFront) {
videoRotation = (cameraInfo.orientation + 270) % 360;
} else {
videoRotation = (cameraInfo.orientation + 90) % 360;
}
break;
case OutputRotation.rotation180:
videoRotation = (cameraInfo.orientation + 180) % 360;
break;
case OutputRotation.rotation270:
if (cameraInfo.facing == CameraInfo.cameraFacingFront) {
videoRotation = (cameraInfo.orientation + 90) % 360;
} else {
videoRotation = (cameraInfo.orientation + 270) % 360;
}
break;
}
return mediaRecorder.setOrientationHint(videoRotation);
}