Closed nermolov closed 1 year ago
Video stops
Async call to VideoController.stopRecordingVideo() never finishes
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(); }, ), ) ], ))); } }
Still having the same issue, is there a reason why this issue occurs?
This issue should be fixed with #145 Feel free to reopen if not 👍
Steps to Reproduce
Expected results
Video stops
Actual results
Async call to VideoController.stopRecordingVideo() never finishes
About your device
Code: