Reason Pun

清理了视频录制页面按钮(可通过此次提交恢复)

升级了插件版本
...@@ -23,20 +23,10 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -23,20 +23,10 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
23 File? _imageFile; 23 File? _imageFile;
24 File? _videoFile; 24 File? _videoFile;
25 25
26 - // Initial values 26 + final bool _isVideoCameraSelected = true;
27 bool _isCameraInitialized = false; 27 bool _isCameraInitialized = false;
28 bool _isRearCameraSelected = true; 28 bool _isRearCameraSelected = true;
29 - bool _isVideoCameraSelected = false;
30 bool _isRecordingInProgress = false; 29 bool _isRecordingInProgress = false;
31 - double _minAvailableExposureOffset = 0.0;
32 - double _maxAvailableExposureOffset = 0.0;
33 - double _minAvailableZoom = 1.0;
34 - double _maxAvailableZoom = 1.0;
35 -
36 - // Current values
37 - double _currentZoomLevel = 1.0;
38 - double _currentExposureOffset = 0.0;
39 - FlashMode? _currentFlashMode;
40 30
41 List<File> allFileList = []; 31 List<File> allFileList = [];
42 32
...@@ -193,11 +183,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -193,11 +183,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
193 } 183 }
194 } 184 }
195 185
196 - void resetCameraValues() async {
197 - _currentZoomLevel = 1.0;
198 - _currentExposureOffset = 0.0;
199 - }
200 -
201 void onNewCameraSelected(CameraDescription cameraDescription) async { 186 void onNewCameraSelected(CameraDescription cameraDescription) async {
202 final previousCameraController = controller; 187 final previousCameraController = controller;
203 188
...@@ -209,8 +194,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -209,8 +194,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
209 194
210 await previousCameraController?.dispose(); 195 await previousCameraController?.dispose();
211 196
212 - resetCameraValues();
213 -
214 if (mounted) { 197 if (mounted) {
215 setState(() { 198 setState(() {
216 controller = cameraController; 199 controller = cameraController;
...@@ -224,22 +207,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -224,22 +207,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
224 207
225 try { 208 try {
226 await cameraController.initialize(); 209 await cameraController.initialize();
227 - await Future.wait([
228 - cameraController
229 - .getMinExposureOffset()
230 - .then((value) => _minAvailableExposureOffset = value),
231 - cameraController
232 - .getMaxExposureOffset()
233 - .then((value) => _maxAvailableExposureOffset = value),
234 - cameraController
235 - .getMaxZoomLevel()
236 - .then((value) => _maxAvailableZoom = value),
237 - cameraController
238 - .getMinZoomLevel()
239 - .then((value) => _minAvailableZoom = value),
240 - ]);
241 -
242 - _currentFlashMode = controller!.value.flashMode;
243 } on CameraException catch (e) { 210 } on CameraException catch (e) {
244 // print('Error initializing camera: $e'); 211 // print('Error initializing camera: $e');
245 } 212 }
...@@ -280,11 +247,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -280,11 +247,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
280 child: Scaffold( 247 child: Scaffold(
281 backgroundColor: Colors.black, 248 backgroundColor: Colors.black,
282 body: _isCameraInitialized 249 body: _isCameraInitialized
283 - ? Column( 250 + ? Stack(
284 - children: [
285 - AspectRatio(
286 - aspectRatio: 1 / controller!.value.aspectRatio,
287 - child: Stack(
288 children: [ 251 children: [
289 controller!.buildPreview(), 252 controller!.buildPreview(),
290 Padding( 253 Padding(
...@@ -297,140 +260,17 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -297,140 +260,17 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
297 child: Column( 260 child: Column(
298 crossAxisAlignment: CrossAxisAlignment.end, 261 crossAxisAlignment: CrossAxisAlignment.end,
299 children: [ 262 children: [
300 - Align(
301 - alignment: Alignment.topRight,
302 - child: Container(
303 - decoration: BoxDecoration(
304 - color: Colors.black87,
305 - borderRadius: BorderRadius.circular(10.0),
306 - ),
307 - child: Padding(
308 - padding: const EdgeInsets.only(
309 - left: 8.0,
310 - right: 8.0,
311 - ),
312 - child: DropdownButton<ResolutionPreset>(
313 - dropdownColor: Colors.black87,
314 - underline: Container(),
315 - value: currentResolutionPreset,
316 - items: [
317 - for (ResolutionPreset preset
318 - in resolutionPresets)
319 - DropdownMenuItem(
320 - child: Text(
321 - preset
322 - .toString()
323 - .split('.')[1]
324 - .toUpperCase(),
325 - style: const TextStyle(
326 - color: Colors.white),
327 - ),
328 - value: preset,
329 - )
330 - ],
331 - onChanged: (value) {
332 - setState(() {
333 - currentResolutionPreset = value!;
334 - _isCameraInitialized = false;
335 - });
336 - onNewCameraSelected(
337 - controller!.description);
338 - },
339 - hint: const Text("Select item"),
340 - ),
341 - ),
342 - ),
343 - ),
344 // Spacer(), 263 // Spacer(),
345 - Padding( 264 + const Spacer(
346 - padding: const EdgeInsets.only( 265 + flex: 1,
347 - right: 8.0, top: 16.0),
348 - child: Container(
349 - decoration: BoxDecoration(
350 - color: Colors.white,
351 - borderRadius: BorderRadius.circular(10.0),
352 - ),
353 - child: Padding(
354 - padding: const EdgeInsets.all(8.0),
355 - child: Text(
356 - _currentExposureOffset
357 - .toStringAsFixed(1) +
358 - 'x',
359 - style:
360 - const TextStyle(color: Colors.black),
361 - ),
362 - ),
363 - ),
364 - ),
365 - Expanded(
366 - child: RotatedBox(
367 - quarterTurns: 3,
368 - child: SizedBox(
369 - height: 30,
370 - child: Slider(
371 - value: _currentExposureOffset,
372 - min: _minAvailableExposureOffset,
373 - max: _maxAvailableExposureOffset,
374 - activeColor: Colors.white,
375 - inactiveColor: Colors.white30,
376 - onChanged: (value) async {
377 - setState(() {
378 - _currentExposureOffset = value;
379 - });
380 - await controller!
381 - .setExposureOffset(value);
382 - },
383 - ),
384 - ),
385 - ),
386 - ),
387 - Row(
388 - children: [
389 - Expanded(
390 - child: Slider(
391 - value: _currentZoomLevel,
392 - min: _minAvailableZoom,
393 - max: _maxAvailableZoom,
394 - activeColor: Colors.white,
395 - inactiveColor: Colors.white30,
396 - onChanged: (value) async {
397 - setState(() {
398 - _currentZoomLevel = value;
399 - });
400 - await controller!.setZoomLevel(value);
401 - },
402 - ),
403 - ),
404 - Padding(
405 - padding: const EdgeInsets.only(right: 8.0),
406 - child: Container(
407 - decoration: BoxDecoration(
408 - color: Colors.black87,
409 - borderRadius:
410 - BorderRadius.circular(10.0),
411 - ),
412 - child: Padding(
413 - padding: const EdgeInsets.all(8.0),
414 - child: Text(
415 - _currentZoomLevel.toStringAsFixed(1) +
416 - 'x',
417 - style: const TextStyle(
418 - color: Colors.white),
419 - ),
420 - ),
421 - ),
422 - ),
423 - ],
424 ), 266 ),
425 Row( 267 Row(
426 - mainAxisAlignment: 268 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
427 - MainAxisAlignment.spaceBetween,
428 children: [ 269 children: [
429 InkWell( 270 InkWell(
430 onTap: _isRecordingInProgress 271 onTap: _isRecordingInProgress
431 ? () async { 272 ? () async {
432 - if (controller! 273 + if (controller!.value.isRecordingPaused) {
433 - .value.isRecordingPaused) {
434 await resumeVideoRecording(); 274 await resumeVideoRecording();
435 } else { 275 } else {
436 await pauseVideoRecording(); 276 await pauseVideoRecording();
...@@ -456,8 +296,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -456,8 +296,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
456 size: 60, 296 size: 60,
457 ), 297 ),
458 _isRecordingInProgress 298 _isRecordingInProgress
459 - ? controller! 299 + ? controller!.value.isRecordingPaused
460 - .value.isRecordingPaused
461 ? const Icon( 300 ? const Icon(
462 Icons.play_arrow, 301 Icons.play_arrow,
463 color: Colors.white, 302 color: Colors.white,
...@@ -479,23 +318,19 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -479,23 +318,19 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
479 ), 318 ),
480 ), 319 ),
481 InkWell( 320 InkWell(
482 - onTap: _isVideoCameraSelected 321 + onTap: () async {
483 - ? () async {
484 if (_isRecordingInProgress) { 322 if (_isRecordingInProgress) {
485 - XFile? rawVideo = 323 + XFile? rawVideo = await stopVideoRecording();
486 - await stopVideoRecording(); 324 + File videoFile = File(rawVideo!.path);
487 - File videoFile =
488 - File(rawVideo!.path);
489 325
490 - int currentUnix = DateTime.now() 326 + int currentUnix =
491 - .millisecondsSinceEpoch; 327 + DateTime.now().millisecondsSinceEpoch;
492 328
493 final directory = 329 final directory =
494 await getApplicationDocumentsDirectory(); 330 await getApplicationDocumentsDirectory();
495 331
496 - String fileFormat = videoFile.path 332 + String fileFormat =
497 - .split('.') 333 + videoFile.path.split('.').last;
498 - .last;
499 334
500 _videoFile = await videoFile.copy( 335 _videoFile = await videoFile.copy(
501 '${directory.path}/$currentUnix.$fileFormat', 336 '${directory.path}/$currentUnix.$fileFormat',
...@@ -505,26 +340,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -505,26 +340,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
505 } else { 340 } else {
506 await startVideoRecording(); 341 await startVideoRecording();
507 } 342 }
508 - }
509 - : () async {
510 - XFile? rawImage =
511 - await takePicture();
512 - File imageFile =
513 - File(rawImage!.path);
514 -
515 - int currentUnix = DateTime.now()
516 - .millisecondsSinceEpoch;
517 -
518 - final directory =
519 - await getApplicationDocumentsDirectory();
520 -
521 - String fileFormat =
522 - imageFile.path.split('.').last;
523 - await imageFile.copy(
524 - '${directory.path}/$currentUnix.$fileFormat',
525 - );
526 -
527 - refreshAlreadyCapturedImages();
528 }, 343 },
529 child: Stack( 344 child: Stack(
530 alignment: Alignment.center, 345 alignment: Alignment.center,
...@@ -555,13 +370,11 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -555,13 +370,11 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
555 ), 370 ),
556 ), 371 ),
557 InkWell( 372 InkWell(
558 - onTap: 373 + onTap: _imageFile != null || _videoFile != null
559 - _imageFile != null || _videoFile != null
560 ? () { 374 ? () {
561 Navigator.of(context).push( 375 Navigator.of(context).push(
562 MaterialPageRoute( 376 MaterialPageRoute(
563 - builder: (context) => 377 + builder: (context) => PreviewScreen(
564 - PreviewScreen(
565 imageFile: _imageFile!, 378 imageFile: _imageFile!,
566 fileList: allFileList, 379 fileList: allFileList,
567 ), 380 ),
...@@ -574,8 +387,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -574,8 +387,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
574 height: 60, 387 height: 60,
575 decoration: BoxDecoration( 388 decoration: BoxDecoration(
576 color: Colors.black, 389 color: Colors.black,
577 - borderRadius: 390 + borderRadius: BorderRadius.circular(10.0),
578 - BorderRadius.circular(10.0),
579 border: Border.all( 391 border: Border.all(
580 color: Colors.white, 392 color: Colors.white,
581 width: 2, 393 width: 2,
...@@ -588,16 +400,14 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -588,16 +400,14 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
588 : null, 400 : null,
589 ), 401 ),
590 child: videoController != null && 402 child: videoController != null &&
591 - videoController! 403 + videoController!.value.isInitialized
592 - .value.isInitialized
593 ? ClipRRect( 404 ? ClipRRect(
594 borderRadius: 405 borderRadius:
595 BorderRadius.circular(8.0), 406 BorderRadius.circular(8.0),
596 child: AspectRatio( 407 child: AspectRatio(
597 aspectRatio: videoController! 408 aspectRatio: videoController!
598 .value.aspectRatio, 409 .value.aspectRatio,
599 - child: VideoPlayer( 410 + child: VideoPlayer(videoController!),
600 - videoController!),
601 ), 411 ),
602 ) 412 )
603 : Container(), 413 : Container(),
...@@ -609,155 +419,10 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -609,155 +419,10 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
609 ), 419 ),
610 ), 420 ),
611 ], 421 ],
612 - ),
613 - ),
614 - Expanded(
615 - child: SingleChildScrollView(
616 - physics: const BouncingScrollPhysics(),
617 - child: Column(
618 - children: [
619 - Padding(
620 - padding: const EdgeInsets.only(top: 8.0),
621 - child: Row(
622 - children: [
623 - Expanded(
624 - child: Padding(
625 - padding: const EdgeInsets.only(
626 - left: 8.0,
627 - right: 4.0,
628 - ),
629 - child: TextButton(
630 - onPressed: _isRecordingInProgress
631 - ? null
632 - : () {
633 - if (_isVideoCameraSelected) {
634 - setState(() {
635 - _isVideoCameraSelected =
636 - false;
637 - });
638 - }
639 - },
640 - style: TextButton.styleFrom(
641 - primary: _isVideoCameraSelected
642 - ? Colors.black54
643 - : Colors.black,
644 - backgroundColor: _isVideoCameraSelected
645 - ? Colors.white30
646 - : Colors.white,
647 - ),
648 - child: const Text('IMAGE'),
649 - ),
650 - ),
651 - ),
652 - Expanded(
653 - child: Padding(
654 - padding: const EdgeInsets.only(
655 - left: 4.0, right: 8.0),
656 - child: TextButton(
657 - onPressed: () {
658 - if (!_isVideoCameraSelected) {
659 - setState(() {
660 - _isVideoCameraSelected = true;
661 - });
662 - }
663 - },
664 - style: TextButton.styleFrom(
665 - primary: _isVideoCameraSelected
666 - ? Colors.black
667 - : Colors.black54,
668 - backgroundColor: _isVideoCameraSelected
669 - ? Colors.white
670 - : Colors.white30,
671 - ),
672 - child: const Text('VIDEO'),
673 - ),
674 - ),
675 - ),
676 - ],
677 - ),
678 - ),
679 - Padding(
680 - padding:
681 - const EdgeInsets.fromLTRB(16.0, 8.0, 16.0, 8.0),
682 - child: Row(
683 - mainAxisAlignment: MainAxisAlignment.spaceBetween,
684 - children: [
685 - InkWell(
686 - onTap: () async {
687 - setState(() {
688 - _currentFlashMode = FlashMode.off;
689 - });
690 - await controller!.setFlashMode(
691 - FlashMode.off,
692 - );
693 - },
694 - child: Icon(
695 - Icons.flash_off,
696 - color: _currentFlashMode == FlashMode.off
697 - ? Colors.amber
698 - : Colors.white,
699 - ),
700 - ),
701 - InkWell(
702 - onTap: () async {
703 - setState(() {
704 - _currentFlashMode = FlashMode.auto;
705 - });
706 - await controller!.setFlashMode(
707 - FlashMode.auto,
708 - );
709 - },
710 - child: Icon(
711 - Icons.flash_auto,
712 - color: _currentFlashMode == FlashMode.auto
713 - ? Colors.amber
714 - : Colors.white,
715 - ),
716 - ),
717 - InkWell(
718 - onTap: () async {
719 - setState(() {
720 - _currentFlashMode = FlashMode.always;
721 - });
722 - await controller!.setFlashMode(
723 - FlashMode.always,
724 - );
725 - },
726 - child: Icon(
727 - Icons.flash_on,
728 - color: _currentFlashMode == FlashMode.always
729 - ? Colors.amber
730 - : Colors.white,
731 - ),
732 - ),
733 - InkWell(
734 - onTap: () async {
735 - setState(() {
736 - _currentFlashMode = FlashMode.torch;
737 - });
738 - await controller!.setFlashMode(
739 - FlashMode.torch,
740 - );
741 - },
742 - child: Icon(
743 - Icons.highlight,
744 - color: _currentFlashMode == FlashMode.torch
745 - ? Colors.amber
746 - : Colors.white,
747 - ),
748 - ),
749 - ],
750 - ),
751 - )
752 - ],
753 - ),
754 - ),
755 - ),
756 - ],
757 ) 422 )
758 : const Center( 423 : const Center(
759 child: Text( 424 child: Text(
760 - 'LOADING', 425 + '开启摄像头..',
761 style: TextStyle(color: Colors.white), 426 style: TextStyle(color: Colors.white),
762 ), 427 ),
763 ), 428 ),
......
...@@ -32,7 +32,7 @@ class PreviewScreen extends StatelessWidget { ...@@ -32,7 +32,7 @@ class PreviewScreen extends StatelessWidget {
32 ), 32 ),
33 ); 33 );
34 }, 34 },
35 - child: Text('Go to all captures'), 35 + child: const Text('打开全部视频'),
36 style: TextButton.styleFrom( 36 style: TextButton.styleFrom(
37 primary: Colors.black, 37 primary: Colors.black,
38 backgroundColor: Colors.white, 38 backgroundColor: Colors.white,
......
...@@ -1118,7 +1118,7 @@ packages: ...@@ -1118,7 +1118,7 @@ packages:
1118 name: url_launcher_macos 1118 name: url_launcher_macos
1119 url: "https://pub.dartlang.org" 1119 url: "https://pub.dartlang.org"
1120 source: hosted 1120 source: hosted
1121 - version: "2.0.2" 1121 + version: "2.0.3"
1122 url_launcher_platform_interface: 1122 url_launcher_platform_interface:
1123 dependency: transitive 1123 dependency: transitive
1124 description: 1124 description:
...@@ -1181,7 +1181,7 @@ packages: ...@@ -1181,7 +1181,7 @@ packages:
1181 name: video_player 1181 name: video_player
1182 url: "https://pub.dartlang.org" 1182 url: "https://pub.dartlang.org"
1183 source: hosted 1183 source: hosted
1184 - version: "2.2.13" 1184 + version: "2.2.15"
1185 video_player_platform_interface: 1185 video_player_platform_interface:
1186 dependency: transitive 1186 dependency: transitive
1187 description: 1187 description:
......