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.

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