NativeVideo constructor

NativeVideo({
  1. Key? key,
  2. required Player player,
  3. double? width,
  4. double? height,
  5. BoxFit fit = BoxFit.contain,
  6. AlignmentGeometry alignment = Alignment.center,
  7. double scale = 1.0,
  8. bool showControls = true,
  9. Color? progressBarActiveColor,
  10. Color? progressBarInactiveColor = Colors.white24,
  11. Color? progressBarThumbColor,
  12. Color? progressBarThumbGlowColor = const Color.fromRGBO(0, 161, 214, .2),
  13. Color? volumeActiveColor,
  14. Color? volumeInactiveColor = Colors.grey,
  15. Color volumeBackgroundColor = const Color(0xff424242),
  16. Color? volumeThumbColor,
  17. double? progressBarThumbRadius = 10.0,
  18. double? progressBarThumbGlowRadius = 15.0,
  19. bool showTimeLeft = false,
  20. TextStyle progressBarTextStyle = const TextStyle(),
  21. FilterQuality filterQuality = FilterQuality.low,
})

A widget for showing video inside the Widget tree. This Widget is more performant compared to Video & uses flutter_native_view to embed the video output directly without any texture interop or pixel-buffer copy calls.

But, it is highly dependent on platform & other limitations apply. In general, this widget is more performant & should be used if possible.

An example configuration between a Player and a NativeVideo can be as follows.

Register the plugin with useFlutterNativeView.

DartVLC.initilize(useFlutterNativeView: true);

Pass registerTexture as false when creating Player & use NativeVideo widget.

class _MyAppState extends State<MyApp> {
  Player player = Player(id: 0, registerTexture: false);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: NativeVideo(
          player: player,
          height: 420.0,
          width: 320.0
        ),
      ),
    );
  }
}

Supported Platforms

  • x Windows

This Widget internally uses StreamController. Prefer calling Player.stop & NativeVideo.dispose to freed the resources. A global Key may be used for this purpose.

Implementation

NativeVideo({
  Key? key,
  required Player player,
  this.width,
  this.height,
  this.fit: BoxFit.contain,
  this.alignment: Alignment.center,
  this.scale: 1.0,
  this.showControls: true,
  this.progressBarActiveColor,
  this.progressBarInactiveColor = Colors.white24,
  this.progressBarThumbColor,
  this.progressBarThumbGlowColor = const Color.fromRGBO(0, 161, 214, .2),
  this.volumeActiveColor,
  this.volumeInactiveColor = Colors.grey,
  this.volumeBackgroundColor = const Color(0xff424242),
  this.volumeThumbColor,
  this.progressBarThumbRadius = 10.0,
  this.progressBarThumbGlowRadius = 15.0,
  this.showTimeLeft = false,
  this.progressBarTextStyle = const TextStyle(),
  this.filterQuality = FilterQuality.low,
})  : player = player,
      super(key: key);