CamerAwesome icon indicating copy to clipboard operation
CamerAwesome copied to clipboard

Call to VideoController.stopRecordingVideo() never finishes

Open nermolov opened this issue 4 years ago • 1 comments

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();
                    },
                  ),
                )
              ],
            )));
  }
}

nermolov avatar Feb 08 '21 02:02 nermolov

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

SethuSenthil avatar Sep 26 '21 19:09 SethuSenthil

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

istornz avatar Dec 27 '22 14:12 istornz