@@ -57,18 +57,49 @@ class MethodChannelVlcPlayer extends VlcPlayerPlatform {
5757 /// can be rendered.
5858 /// The `viewId` is passed as a parameter from the framework on the
5959 /// `onPlatformViewCreated` callback.
60+ ///
61+ /// The `virtualDisplay` specifies whether Virtual displays or Hybrid composition is used on Android.
62+ /// iOS only uses Hybrid composition.
6063 @override
61- Widget buildView (PlatformViewCreatedCallback onPlatformViewCreated) {
64+ Widget buildView (PlatformViewCreatedCallback onPlatformViewCreated, {bool virtualDisplay = true }) {
65+ const viewType = 'flutter_video_plugin/getVideoView' ;
6266 if (Platform .isAndroid) {
63- return AndroidView (
64- viewType: 'flutter_video_plugin/getVideoView' ,
65- hitTestBehavior: PlatformViewHitTestBehavior .transparent,
66- onPlatformViewCreated: onPlatformViewCreated,
67- creationParamsCodec: const StandardMessageCodec (),
68- );
67+ if (virtualDisplay) {
68+ return AndroidView (
69+ viewType: viewType,
70+ hitTestBehavior: PlatformViewHitTestBehavior .transparent,
71+ onPlatformViewCreated: onPlatformViewCreated,
72+ creationParamsCodec: const StandardMessageCodec (),
73+ );
74+ } else {
75+ return PlatformViewLink (
76+ viewType: viewType,
77+ surfaceFactory: (
78+ BuildContext context,
79+ PlatformViewController controller,
80+ ) {
81+ return AndroidViewSurface (
82+ controller: controller as AndroidViewController ,
83+ gestureRecognizers: const {},
84+ hitTestBehavior: PlatformViewHitTestBehavior .transparent,
85+ );
86+ },
87+ onCreatePlatformView: (PlatformViewCreationParams params) {
88+ return PlatformViewsService .initSurfaceAndroidView (
89+ id: params.id,
90+ viewType: viewType,
91+ layoutDirection: TextDirection .ltr,
92+ creationParamsCodec: const StandardMessageCodec (),
93+ )
94+ ..addOnPlatformViewCreatedListener (params.onPlatformViewCreated)
95+ ..addOnPlatformViewCreatedListener (onPlatformViewCreated)
96+ ..create ();
97+ },
98+ );
99+ }
69100 } else if (Platform .isIOS) {
70101 return UiKitView (
71- viewType: 'flutter_video_plugin/getVideoView' ,
102+ viewType: viewType ,
72103 onPlatformViewCreated: onPlatformViewCreated,
73104 hitTestBehavior: PlatformViewHitTestBehavior .transparent,
74105 creationParamsCodec: const StandardMessageCodec (),
0 commit comments