You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.4KB

  1. import 'dart:async';
  2. import 'dart:io';
  3. import 'package:flutter/material.dart';
  4. class VideoWidget extends StatefulWidget {
  5. final bool play;
  6. final bool isServerFile;
  7. final String pathFile;
  8. const VideoWidget({
  9. Key? key,
  10. required this.pathFile,
  11. required this.play,
  12. required this.isServerFile,
  13. }) : super(key: key);
  14. @override
  15. _VideoWidgetState createState() => _VideoWidgetState();
  16. }
  17. class _VideoWidgetState extends State<VideoWidget> {
  18. // VideoPlayerController videoPlayerController;
  19. // Future<void> _initializeVideoPlayerFuture;
  20. @override
  21. void initState() {
  22. super.initState();
  23. // if (widget.isServerFile) {
  24. // videoPlayerController = VideoPlayerController.network(widget.pathFile);
  25. // } else {
  26. // videoPlayerController = VideoPlayerController.file(File(widget.pathFile));
  27. // }
  28. // _initializeVideoPlayerFuture = videoPlayerController.initialize().then((_) {
  29. // // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
  30. // videoPlayerController.play();
  31. // videoPlayerController.setVolume(0.0);
  32. // Timer.periodic(Duration(seconds: 1), (_) {
  33. // videoPlayerController.pause();
  34. // });
  35. // setState(() {});
  36. // });
  37. }
  38. @override
  39. void dispose() {
  40. // videoPlayerController.dispose();
  41. print("dispose video item");
  42. super.dispose();
  43. }
  44. @override
  45. Widget build(BuildContext context) {
  46. return Container(
  47. child: Text('VideoWidget'),
  48. );
  49. // return FutureBuilder(
  50. // future: _initializeVideoPlayerFuture,
  51. // builder: (context, snapshot) {
  52. // if (snapshot.connectionState == ConnectionState.done) {
  53. // return new Container(
  54. // child: Container(
  55. // key: new PageStorageKey(widget.pathFile),
  56. // child: Container(
  57. // padding: EdgeInsets.all(1),
  58. // width: 100,
  59. // height: 100,
  60. // decoration: BoxDecoration(
  61. // color: Colors.white,
  62. // border: Border.all(color: Colors.red),
  63. // borderRadius: BorderRadius.all(Radius.circular(8.0))),
  64. // child: VideoPlayer(videoPlayerController),
  65. // ),
  66. // ),
  67. // );
  68. // } else {
  69. // return Center(
  70. // child: CircularProgressIndicator(),
  71. // );
  72. // }
  73. // },
  74. // );
  75. }
  76. }