|
1 |
| -import 'dart:io'; |
| 1 | +// import 'dart:io'; |
2 | 2 |
|
3 |
| -import 'package:flutter/gestures.dart'; |
4 |
| -import 'package:flutter/material.dart'; |
5 |
| -import 'package:flutter_quill/flutter_quill.dart'; |
6 |
| -import 'package:url_launcher/url_launcher.dart'; |
7 |
| -import 'package:video_player/video_player.dart'; |
| 3 | +// import 'package:flutter/gestures.dart'; |
| 4 | +// import 'package:flutter/material.dart'; |
| 5 | +// import 'package:flutter_quill/flutter_quill.dart'; |
| 6 | +// import 'package:url_launcher/url_launcher.dart'; |
| 7 | +// import 'package:video_player/video_player.dart'; |
8 | 8 |
|
9 |
| -/// Widget for playing back video |
10 |
| -/// Refer to https://github.com/flutter/plugins/tree/master/packages/video_player/video_player |
11 |
| -class VideoApp extends StatefulWidget { |
12 |
| - const VideoApp({ |
13 |
| - required this.videoUrl, |
14 |
| - required this.context, |
15 |
| - required this.readOnly, |
16 |
| - this.onVideoInit, |
17 |
| - }); |
| 9 | +// /// Widget for playing back video |
| 10 | +// /// Refer to https://github.com/flutter/plugins/tree/master/packages/video_player/video_player |
| 11 | +// class VideoApp extends StatefulWidget { |
| 12 | +// const VideoApp({ |
| 13 | +// required this.videoUrl, |
| 14 | +// required this.context, |
| 15 | +// required this.readOnly, |
| 16 | +// this.onVideoInit, |
| 17 | +// }); |
18 | 18 |
|
19 |
| - final String videoUrl; |
20 |
| - final BuildContext context; |
21 |
| - final bool readOnly; |
22 |
| - final void Function(GlobalKey videoContainerKey)? onVideoInit; |
| 19 | +// final String videoUrl; |
| 20 | +// final BuildContext context; |
| 21 | +// final bool readOnly; |
| 22 | +// final void Function(GlobalKey videoContainerKey)? onVideoInit; |
23 | 23 |
|
24 |
| - @override |
25 |
| - _VideoAppState createState() => _VideoAppState(); |
26 |
| -} |
| 24 | +// @override |
| 25 | +// _VideoAppState createState() => _VideoAppState(); |
| 26 | +// } |
27 | 27 |
|
28 |
| -class _VideoAppState extends State<VideoApp> { |
29 |
| - late VideoPlayerController _controller; |
30 |
| - GlobalKey videoContainerKey = GlobalKey(); |
| 28 | +// class _VideoAppState extends State<VideoApp> { |
| 29 | +// late VideoPlayerController _controller; |
| 30 | +// GlobalKey videoContainerKey = GlobalKey(); |
31 | 31 |
|
32 |
| - @override |
33 |
| - void initState() { |
34 |
| - super.initState(); |
| 32 | +// @override |
| 33 | +// void initState() { |
| 34 | +// super.initState(); |
35 | 35 |
|
36 |
| - _controller = widget.videoUrl.startsWith('http') |
37 |
| - ? VideoPlayerController.networkUrl(Uri.parse(widget.videoUrl)) |
38 |
| - : VideoPlayerController.file(File(widget.videoUrl)) |
39 |
| - ..initialize().then((_) { |
40 |
| - // Ensure the first frame is shown after the video is initialized, |
41 |
| - // even before the play button has been pressed. |
42 |
| - setState(() {}); |
43 |
| - if (widget.onVideoInit != null) { |
44 |
| - widget.onVideoInit?.call(videoContainerKey); |
45 |
| - } |
46 |
| - }).catchError((error) { |
47 |
| - setState(() {}); |
48 |
| - }); |
49 |
| - } |
50 | 36 |
|
51 |
| - @override |
52 |
| - Widget build(BuildContext context) { |
53 |
| - final defaultStyles = DefaultStyles.getInstance(context); |
54 |
| - if (_controller.value.hasError) { |
55 |
| - if (widget.readOnly) { |
56 |
| - return RichText( |
57 |
| - text: TextSpan( |
58 |
| - text: widget.videoUrl, |
59 |
| - style: defaultStyles.link, |
60 |
| - recognizer: TapGestureRecognizer() |
61 |
| - ..onTap = () => launchUrl(Uri.parse(widget.videoUrl))), |
62 |
| - ); |
63 |
| - } |
| 37 | +// _controller = widget.videoUrl.startsWith('http') |
| 38 | +// ? VideoPlayerController.network(widget.videoUrl) |
| 39 | +// : VideoPlayerController.file(File(widget.videoUrl)) |
| 40 | +// ..initialize().then((_) { |
| 41 | +// // Ensure the first frame is shown after the video is initialized, |
| 42 | +// // even before the play button has been pressed. |
| 43 | +// setState(() {}); |
| 44 | +// if (widget.onVideoInit != null) { |
| 45 | +// widget.onVideoInit?.call(videoContainerKey); |
| 46 | +// } |
| 47 | +// }).catchError((error) { |
| 48 | +// setState(() {}); |
| 49 | +// }); |
| 50 | +// } |
64 | 51 |
|
65 |
| - return RichText( |
66 |
| - text: TextSpan(text: widget.videoUrl, style: defaultStyles.link)); |
67 |
| - } else if (!_controller.value.isInitialized) { |
68 |
| - return VideoProgressIndicator( |
69 |
| - _controller, |
70 |
| - allowScrubbing: true, |
71 |
| - colors: const VideoProgressColors(playedColor: Colors.blue), |
72 |
| - ); |
73 |
| - } |
74 | 52 |
|
75 |
| - return Container( |
76 |
| - key: videoContainerKey, |
77 |
| - // height: 300, |
78 |
| - child: InkWell( |
79 |
| - onTap: () { |
80 |
| - setState(() { |
81 |
| - _controller.value.isPlaying |
82 |
| - ? _controller.pause() |
83 |
| - : _controller.play(); |
84 |
| - }); |
85 |
| - }, |
86 |
| - child: Stack(alignment: Alignment.center, children: [ |
87 |
| - Center( |
88 |
| - child: AspectRatio( |
89 |
| - aspectRatio: _controller.value.aspectRatio, |
90 |
| - child: VideoPlayer(_controller), |
91 |
| - )), |
92 |
| - _controller.value.isPlaying |
93 |
| - ? const SizedBox.shrink() |
94 |
| - : Container( |
95 |
| - color: const Color(0xfff5f5f5), |
96 |
| - child: const Icon( |
97 |
| - Icons.play_arrow, |
98 |
| - size: 60, |
99 |
| - color: Colors.blueGrey, |
100 |
| - )) |
101 |
| - ]), |
102 |
| - ), |
103 |
| - ); |
104 |
| - } |
| 53 | +// @override |
| 54 | +// Widget build(BuildContext context) { |
| 55 | +// final defaultStyles = DefaultStyles.getInstance(context); |
| 56 | +// if (_controller.value.hasError) { |
| 57 | +// if (widget.readOnly) { |
| 58 | +// return RichText( |
| 59 | +// text: TextSpan( |
| 60 | +// text: widget.videoUrl, |
| 61 | +// style: defaultStyles.link, |
| 62 | +// recognizer: TapGestureRecognizer() |
| 63 | +// ..onTap = () => launchUrl(Uri.parse(widget.videoUrl))), |
| 64 | +// ); |
| 65 | +// } |
105 | 66 |
|
106 |
| - @override |
107 |
| - void dispose() { |
108 |
| - super.dispose(); |
109 |
| - _controller.dispose(); |
110 |
| - } |
111 |
| -} |
| 67 | +// return RichText( |
| 68 | +// text: TextSpan(text: widget.videoUrl, style: defaultStyles.link)); |
| 69 | +// } else if (!_controller.value.isInitialized) { |
| 70 | +// return VideoProgressIndicator( |
| 71 | +// _controller, |
| 72 | +// allowScrubbing: true, |
| 73 | +// colors: const VideoProgressColors(playedColor: Colors.blue), |
| 74 | +// ); |
| 75 | +// } |
| 76 | + |
| 77 | +// return Container( |
| 78 | +// key: videoContainerKey, |
| 79 | +// // height: 300, |
| 80 | +// child: InkWell( |
| 81 | +// onTap: () { |
| 82 | +// setState(() { |
| 83 | +// _controller.value.isPlaying |
| 84 | +// ? _controller.pause() |
| 85 | +// : _controller.play(); |
| 86 | +// }); |
| 87 | +// }, |
| 88 | +// child: Stack(alignment: Alignment.center, children: [ |
| 89 | +// Center( |
| 90 | +// child: AspectRatio( |
| 91 | +// aspectRatio: _controller.value.aspectRatio, |
| 92 | +// child: VideoPlayer(_controller), |
| 93 | +// )), |
| 94 | +// _controller.value.isPlaying |
| 95 | +// ? const SizedBox.shrink() |
| 96 | +// : Container( |
| 97 | +// color: const Color(0xfff5f5f5), |
| 98 | +// child: const Icon( |
| 99 | +// Icons.play_arrow, |
| 100 | +// size: 60, |
| 101 | +// color: Colors.blueGrey, |
| 102 | +// )) |
| 103 | +// ]), |
| 104 | +// ), |
| 105 | +// ); |
| 106 | +// } |
| 107 | + |
| 108 | +// @override |
| 109 | +// void dispose() { |
| 110 | +// super.dispose(); |
| 111 | +// _controller.dispose(); |
| 112 | +// } |
| 113 | +// } |
0 commit comments