Apparence-io / CamerAwesome

📸 Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
952 stars 241 forks source link

Call to VideoController.stopRecordingVideo() never finishes #77

Closed nermolov closed 1 year ago

nermolov commented 3 years ago

Steps to Reproduce

  1. Run code at bottom of issue
  2. Try starting then stopping video

Expected results

Video stops

Actual results

Async call to VideoController.stopRecordingVideo() never finishes

About your device

Brand Model OS
Apple iPhone Xs 14.2

Code:

import 'package:flutter/material.dart';
import 'dart:io';
import 'package:camerawesome/camerawesome_plugin.dart';
import 'package:path_provider/path_provider.dart';

class WalkCamera extends StatefulWidget {
  WalkCamera({Key key}) : super(key: key);

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

class _WalkCameraState extends State<WalkCamera> {
  ValueNotifier<Sensors> _sensor = ValueNotifier(Sensors.BACK);
  ValueNotifier<CaptureModes> _captureMode = ValueNotifier(CaptureModes.VIDEO);
  ValueNotifier<Size> _photoSize = ValueNotifier(null);

  VideoController _videoController = new VideoController();

  List<Size> availableSizes;

  bool recording = false;
  String videoPath;

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  recordVideo() async {
    setState(() {
      recording = true;
    });
    final Directory extDir = await getTemporaryDirectory();
    videoPath = '${extDir.path}/${DateTime.now().millisecondsSinceEpoch}.mp4';

    print('Recording $videoPath');
    await _videoController.recordVideo(videoPath);
  }

  stopVideo() async {
    setState(() {
      recording = false;
    });
    print('Attempting stop...');
    await _videoController.stopRecordingVideo();

    print('Recorded $videoPath');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.black,
        body: SafeArea(
            bottom: false,
            child: Column(
              children: [
                Expanded(
                  child: CameraAwesome(
                    selectDefaultSize: (availableSizes) {
                      this.availableSizes = availableSizes;
                      return availableSizes[0];
                    },
                    photoSize: _photoSize,
                    sensor: _sensor,
                    captureMode: _captureMode,
                  ),
                ),
                Container(
                  height: 100.0,
                  child: RaisedButton(
                    child:
                        Text(recording ? 'Stop Recording' : 'Start Recording'),
                    onPressed: () {
                      if (recording)
                        stopVideo();
                      else
                        recordVideo();
                    },
                  ),
                )
              ],
            )));
  }
}
SethuSenthil commented 2 years ago

Still having the same issue, is there a reason why this issue occurs?

istornz commented 1 year ago

This issue should be fixed with #145 Feel free to reopen if not 👍