|
1 | 1 | // ignore_for_file: implementation_imports |
2 | 2 | import 'dart:async'; |
| 3 | +import 'dart:io'; |
3 | 4 | import 'dart:typed_data'; |
4 | 5 | import 'dart:ui' as ui; |
5 | 6 | import 'package:flutter/material.dart'; |
6 | | -import 'package:dart_vlc_ffi/src/player.dart'; |
| 7 | +import 'package:dart_vlc_ffi/src/player.dart' hide Player; |
| 8 | +import 'package:dart_vlc/dart_vlc.dart'; |
7 | 9 | import 'package:dart_vlc/src/widgets/controls.dart'; |
8 | 10 |
|
9 | 11 | /// Internally used map to keep [GlobalKey]s for [Video]'s [ControlState]s. |
@@ -69,6 +71,9 @@ class Video extends StatefulWidget { |
69 | 71 | /// Scale. |
70 | 72 | final double scale; |
71 | 73 |
|
| 74 | + /// Filter quality. |
| 75 | + final FilterQuality filterQuality; |
| 76 | + |
72 | 77 | // Built-In video controls. |
73 | 78 | final bool showControls; |
74 | 79 |
|
@@ -127,6 +132,7 @@ class Video extends StatefulWidget { |
127 | 132 | this.progressBarThumbGlowRadius = 15.0, |
128 | 133 | this.showTimeLeft = false, |
129 | 134 | this.progressBarTextStyle = const TextStyle(), |
| 135 | + this.filterQuality = FilterQuality.low, |
130 | 136 | Key? key, |
131 | 137 | }) : super(key: key); |
132 | 138 |
|
@@ -155,58 +161,85 @@ class VideoState extends State<Video> { |
155 | 161 | height: widget.height, |
156 | 162 | width: widget.width, |
157 | 163 | scale: widget.scale, |
158 | | - filterQuality: FilterQuality.low, |
| 164 | + filterQuality: widget.filterQuality, |
159 | 165 | ); |
160 | 166 | } |
161 | 167 |
|
162 | 168 | @override |
163 | 169 | Future<void> dispose() async { |
164 | 170 | super.dispose(); |
165 | | - await videoStreamControllers[widget.playerId]?.close(); |
| 171 | + if (Platform.isWindows) { |
| 172 | + } else { |
| 173 | + await videoStreamControllers[widget.playerId]?.close(); |
| 174 | + } |
166 | 175 | } |
167 | 176 |
|
168 | 177 | @override |
169 | 178 | void initState() { |
170 | 179 | super.initState(); |
171 | | - if (widget.showControls) controls[widget.playerId] = this.controlKey; |
172 | | - videoStreamControllers[widget.playerId] = |
173 | | - new StreamController<VideoFrame>.broadcast(); |
174 | | - videoStreamControllers[widget.playerId]?.stream |
175 | | - .listen((VideoFrame videoFrame) async { |
176 | | - this.videoFrameRawImage = await this.getVideoFrameRawImage(videoFrame); |
177 | | - if (this.mounted) { |
178 | | - this.setState(() {}); |
179 | | - } |
180 | | - }); |
| 180 | + if (Platform.isWindows) { |
| 181 | + } else { |
| 182 | + if (widget.showControls) controls[widget.playerId] = this.controlKey; |
| 183 | + videoStreamControllers[widget.playerId] = |
| 184 | + new StreamController<VideoFrame>.broadcast(); |
| 185 | + videoStreamControllers[widget.playerId] |
| 186 | + ?.stream |
| 187 | + .listen((VideoFrame videoFrame) async { |
| 188 | + this.videoFrameRawImage = await this.getVideoFrameRawImage(videoFrame); |
| 189 | + if (this.mounted) { |
| 190 | + this.setState(() {}); |
| 191 | + } |
| 192 | + }); |
| 193 | + } |
181 | 194 | } |
182 | 195 |
|
183 | 196 | @override |
184 | 197 | Widget build(BuildContext context) { |
185 | 198 | if (widget.showControls) { |
186 | 199 | return Control( |
187 | | - key: this.controlKey, |
188 | | - playerId: widget.playerId, |
189 | | - height: widget.height, |
190 | | - width: widget.width, |
191 | | - progressBarThumbRadius: widget.progressBarThumbRadius, |
192 | | - progressBarThumbGlowRadius: widget.progressBarThumbGlowRadius, |
193 | | - progressBarActiveColor: widget.progressBarActiveColor, |
194 | | - progressBarInactiveColor: widget.progressBarInactiveColor, |
195 | | - progressBarThumbColor: widget.progressBarThumbColor, |
196 | | - progressBarThumbGlowColor: widget.progressBarThumbGlowColor, |
197 | | - volumeActiveColor: widget.volumeActiveColor, |
198 | | - volumeInactiveColor: widget.volumeInactiveColor, |
199 | | - volumeBackgroundColor: widget.volumeBackgroundColor, |
200 | | - volumeThumbColor: widget.volumeThumbColor, |
201 | | - showTimeLeft: widget.showTimeLeft, |
202 | | - progressBarTextStyle: widget.progressBarTextStyle, |
203 | | - child: this.videoFrameRawImage ?? |
204 | | - Container( |
205 | | - color: Colors.black, |
206 | | - height: widget.height, |
207 | | - width: widget.width, |
208 | | - ), |
209 | | - ); |
| 200 | + key: this.controlKey, |
| 201 | + playerId: widget.playerId, |
| 202 | + height: widget.height, |
| 203 | + width: widget.width, |
| 204 | + progressBarThumbRadius: widget.progressBarThumbRadius, |
| 205 | + progressBarThumbGlowRadius: widget.progressBarThumbGlowRadius, |
| 206 | + progressBarActiveColor: widget.progressBarActiveColor, |
| 207 | + progressBarInactiveColor: widget.progressBarInactiveColor, |
| 208 | + progressBarThumbColor: widget.progressBarThumbColor, |
| 209 | + progressBarThumbGlowColor: widget.progressBarThumbGlowColor, |
| 210 | + volumeActiveColor: widget.volumeActiveColor, |
| 211 | + volumeInactiveColor: widget.volumeInactiveColor, |
| 212 | + volumeBackgroundColor: widget.volumeBackgroundColor, |
| 213 | + volumeThumbColor: widget.volumeThumbColor, |
| 214 | + showTimeLeft: widget.showTimeLeft, |
| 215 | + progressBarTextStyle: widget.progressBarTextStyle, |
| 216 | + child: Platform.isWindows |
| 217 | + ? ( |
| 218 | + /* Using flutter::TextureRegistrar for Windows. */ |
| 219 | + ((players[widget.playerId]! as Player).textureId != null) |
| 220 | + ? Container( |
| 221 | + width: widget.width, |
| 222 | + height: widget.height, |
| 223 | + color: Colors.black, |
| 224 | + child: Texture( |
| 225 | + textureId: (players[widget.playerId]! as Player) |
| 226 | + .textureId!, |
| 227 | + filterQuality: widget.filterQuality, |
| 228 | + ), |
| 229 | + ) |
| 230 | + : Container( |
| 231 | + width: widget.width, |
| 232 | + height: widget.height, |
| 233 | + color: Colors.black, |
| 234 | + )) |
| 235 | + : ( |
| 236 | + /* Using NativePorts for Linux. */ |
| 237 | + this.videoFrameRawImage ?? |
| 238 | + Container( |
| 239 | + color: Colors.black, |
| 240 | + height: widget.height, |
| 241 | + width: widget.width, |
| 242 | + ))); |
210 | 243 | } else { |
211 | 244 | return this.videoFrameRawImage ?? |
212 | 245 | Container( |
|
0 commit comments