Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

长按拍摄时报错 #12

Closed
FieeA opened this issue Oct 12, 2020 · 16 comments
Closed

长按拍摄时报错 #12

FieeA opened this issue Oct 12, 2020 · 16 comments

Comments

@FieeA
Copy link

FieeA commented Oct 12, 2020

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

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

@AlexV525
Copy link
Member

提供更多信息?

@FieeA
Copy link
Author

FieeA commented Oct 12, 2020

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
Copy link
Member

更多的报错信息

@FieeA
Copy link
Author

FieeA commented Oct 12, 2020

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
Copy link
Member

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

@AlexV525
Copy link
Member

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

@FieeA
Copy link
Author

FieeA commented Oct 12, 2020

ResolutionPreset调成low,依然不可以

@AlexV525
Copy link
Member

嗯,试下官方demo。

@FieeA
Copy link
Author

FieeA commented Oct 12, 2020

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

@AlexV525
Copy link
Member

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

@FieeA
Copy link
Author

FieeA commented Oct 13, 2020

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

@mrchenmo
Copy link

mrchenmo commented Jul 15, 2021

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

@AlexV525
Copy link
Member

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

@mrchenmo
Copy link

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

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

@AlexV525
Copy link
Member

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

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

@leeyisoft

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants