@@ -39,6 +39,10 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
3939 /// Initialize vlc player when the platform is ready automatically
4040 final bool autoInitialize;
4141
42+ /// Set keep playing video in background, when app goes in background.
43+ /// The default value is false.
44+ final bool allowBackgroundPlayback;
45+
4246 /// This is a callback that will be executed once the platform view has been initialized.
4347 /// If you want the media to play as soon as the platform view has initialized, you could just call
4448 /// [VlcPlayerController.play] in this callback. (see the example).
@@ -91,6 +95,7 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
9195 VlcPlayerController .asset (
9296 this .dataSource, {
9397 this .autoInitialize = true ,
98+ this .allowBackgroundPlayback = false ,
9499 this .package,
95100 this .hwAcc = HwAcc .auto,
96101 this .autoPlay = true ,
@@ -112,6 +117,7 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
112117 VlcPlayerController .network (
113118 this .dataSource, {
114119 this .autoInitialize = true ,
120+ this .allowBackgroundPlayback = false ,
115121 this .hwAcc = HwAcc .auto,
116122 this .autoPlay = true ,
117123 this .options,
@@ -132,6 +138,7 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
132138 VlcPlayerController .file (
133139 File file, {
134140 this .autoInitialize = true ,
141+ this .allowBackgroundPlayback = true ,
135142 this .hwAcc = HwAcc .auto,
136143 this .autoPlay = true ,
137144 this .options,
@@ -177,7 +184,9 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
177184 throw Exception ('Already Initialized' );
178185 }
179186
180- _lifeCycleObserver = VlcAppLifeCycleObserver (this )..initialize ();
187+ if (! allowBackgroundPlayback) {
188+ _lifeCycleObserver = VlcAppLifeCycleObserver (this )..initialize ();
189+ }
181190
182191 await vlcPlayerPlatform.create (
183192 viewId: _viewId,
0 commit comments