fluttercandies / flutter_wechat_camera_picker

A camera picker (take photos and videos) for Flutter projects based on WeChat's UI. It's a standalone module of wechat_assets_picker yet it can be run separately.
https://pub.dev/packages/wechat_camera_picker
Apache License 2.0
365 stars 145 forks source link

长按拍摄时报错 #12

Closed FieeA closed 3 years ago

FieeA commented 3 years ago

当我长按录制视频结束时报错:Error when stop recording video: CameraException(videoRecordingFailed, null),请问该如何解决呢.

flutter版本:1.17.5 dart版本:2.8.4 android版本:5.1

AlexV525 commented 3 years ago

提供更多信息?

FieeA commented 3 years ago
import 'package:flutter/material.dart';
import 'package:wechat_camera_picker/wechat_camera_picker.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: InkWell(
          child: Text('拍摄'),
          onTap: () async {
            final AssetEntity entity = await CameraPicker.pickFromCamera(
                context,
                isAllowRecording: true,
                maximumRecordingDuration: Duration(seconds: 5));
            print(entity);
          },
        ),
      ),
    );
  }
}

这就是全部代码了,还需要其他什么信息吗?

AlexV525 commented 3 years ago

更多的报错信息

FieeA commented 3 years ago
10-12 17:05:30.056 6627-6627/com.example.wechat_cam E/CameraDevice-0-LE: Surface with size (w=1920, h=1080) and format 0x1 is not valid, size not in valid set: [1280x960, 1280x720, 1052x780, 960x720, 960x540, 720x720, 864x480, 720x540, 800x480, 720x480, 768x432, 640x480, 576x432, 480x320, 384x288, 352x288, 320x240, 240x160, 208x144, 176x144, 160x120]
10-12 17:05:30.056 6627-6627/com.example.wechat_cam W/CameraDevice-JV-0: Stream configuration failed
10-12 17:05:30.056 6627-6627/com.example.wechat_cam E/CameraCaptureSession: Session 1: Failed to create capture session; configuration failed
10-12 17:05:32.896 6627-6627/com.example.wechat_cam E/MediaRecorder: stop called in an invalid state: 8

当我触发这个错误后,我又尝试单击拍摄按钮,遇到如下错误

10-12 17:06:41.076 6627-6627/com.example.wechat_cam E/MethodChannel#plugins.flutter.io/camera: Failed to handle method call
    java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.camera2.CameraCaptureSession.capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession$CaptureCallback, android.os.Handler)' on a null object reference
        at io.flutter.plugins.camera.Camera.takePicture(Camera.java:242)
        at io.flutter.plugins.camera.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:77)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
        at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
        at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:143)
        at android.os.Looper.loop(Looper.java:122)
        at android.app.ActivityThread.main(ActivityThread.java:5593)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

希望这些对你有用

AlexV525 commented 3 years ago

目前看起来是官方的camera的问题,试下官方camera的example是否正常

AlexV525 commented 3 years ago

尝试降低一下 ResolutionPreset,看下有没有变化

FieeA commented 3 years ago

ResolutionPreset调成low,依然不可以

AlexV525 commented 3 years ago

嗯,试下官方demo。

FieeA commented 3 years ago

淦...换了个手机就正常了,难道有什么东西不兼容旧设备吗

AlexV525 commented 3 years ago

camera的问题还是很多,所以有些时候与它本身的质量有关...

FieeA commented 3 years ago

那就先这样吧,多谢多谢啊

mrchenmo commented 3 years ago

同样是camera插件的问题,It seems that this issue going to be fixed with this PR: flutter/plugins#3651好像有个PR解决了这个问题,不知道官方有没有合并进去。在某些手机上 Camera2的API不能用。补充一个相同 bug的 issue 链接 https://github.com/flutter/flutter/issues/40519

AlexV525 commented 3 years ago

我也在关注这个PR,PR本身质量不错,但原作者交付的过程太慢,有很多改进已经被拆分到其他地方完成了。

mrchenmo commented 3 years ago

我也在关注这个PR,PR本身质量不错,但原作者交付的过程太慢,有很多改进已经被拆分到其他地方完成了。

好的A少,升级下插件版本呗

AlexV525 commented 3 years ago

好的A少,升级下插件版本呗

flutter pub upgrade 即可,新的使用者下载到的也是新版。

leeyisoft commented 2 years ago

好的A少,升级下插件版本呗

flutter pub upgrade 即可,新的使用者下载到的也是新版。

我的插件升级到目前最新的

  camera: ^0.9.4+16
  wechat_camera_picker: ^3.0.1

红米 5A 还是有问题