I'm having an issue where I try to access the camera and it returns an error, which initially seems to be a machine-related error. However, sites like Meet and Discord can access the camera normally. I discovered that the error is related to having OBS Studio installed, where apparently it takes ownership of the camera, and when I try to access it, the error described in the title occurs. I'm using the package 'camera: ^0.10.5+5', and this is the code:
Future<void> _initializeCamera() async {
try {
cameras = await availableCameras();
if (cameras.isNotEmpty) {
CameraDescription selectedCamera;
if (kIsWeb) {
selectedCamera = cameras.firstWhere(
(camera) => camera.lensDirection == CameraLensDirection.front,
orElse: () => cameras.first,
);
} else {
selectedCamera = cameras.firstWhere(
(camera) => camera.lensDirection == CameraLensDirection.back,
orElse: () => cameras.first,
);
}
_controller = CameraController(
selectedCamera,
ResolutionPreset.low,
imageFormatGroup: ImageFormatGroup.jpeg,
);
await _controller!.initialize().then((_) {
if (!mounted) return;
setState(() {
loading = false;
});
});
} else {
_showNoCameraAvailableDialog();
}
} catch (e) {
_showCameraInitializationErrorDialog(e.toString());
}
}