Я использую плагин флаттера камеры.Когда я начинаю запись в Google Pixel Android 9.0, это дает мне исключение ниже, но отлично работает на других устройствах Android (API-уровень 24).
E/MediaRecorder(24874): prepare failed: -2147483648
E/flutter (24874): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: CameraException(videoRecordingFailed, prepare failed.)
E/flutter (24874): #0 CameraController.startVideoRecording (package:camera/camera.dart:444:7)
E/flutter (24874): <asynchronous suspension>
E/flutter (24874): #1 _CameraScreenState._getBody.<anonymous closure>.<anonymous closure> (package:hardware_access/camera_screen.dart:132:36)
E/flutter (24874): <asynchronous suspension>
E/flutter (24874): #2 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14)
E/flutter (24874): #3 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30)
E/flutter (24874): #4 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
E/flutter (24874): #5 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9)
E/flutter (24874): #6 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:177:9)
E/flutter (24874): #7 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:436:9)
E/flutter (24874): #8 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter (24874): #9 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter (24874): #10 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:221:19)
E/flutter (24874): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:199:22)
E/flutter (24874): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (24874): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (24874): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (24874): #15 _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter (24874): #16 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (24874): #17 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (24874): #18 _invoke1 (dart:ui/hooks.dart:233:10)
E/flutter (24874): #19 _dispatchPointerDataPacket (dart:ui/hooks.dart:154:5)
E/flutter (24874):
Мой виджет выглядит так:
onPressed: () async {
var dir = await PathProvider
.getApplicationDocumentsDirectory();
var dirPath = dir.path;
if (!isRecordingStarted) {
setState(() {
isRecordingStarted = true;
});
await controller
.startVideoRecording(dirPath + "/abc.mp4");
} else {
setState(() {
isRecordingStarted = false;
});
await controller.stopVideoRecording();
}
},