5

I was trying to implement full screen with the flutter_vlc_player but wasn’t able because it is always returning “already initialized” so how can I get the same instance of that VLC Player to show in full screen?

chaempain
  • 105
  • 1
  • 5

2 Answers2

2

The main trick is to wrap the VLCPlayer inside an AspectRatio and optionally inside a Transform if you would like to sale the video.

As the flutter_vlc_player plugin behaves unintuitive in some ways, I have prepared a sample project on Github to demonstrate the setup.

Assuming your app is displayed in landscape mode and the video is in 16 / 9 format:

final screenSize = MediaQuery.of(context).size;

final vlcPlayer = VlcPlayer(
    controller: vlcController,
    aspectRatio: screenSize.width / screenSize.height,
    placeholder: const Center(child: CircularProgressIndicator()));


Scaffold(
  body: Stack(
     children: [
        Container(
          // Background behind the video
          color: Colors.black,
        ),
        Center(
            child: AspectRatio(aspectRatio: 16 / 9, child: vlcPlayer)),
     ],
  ),
)

enter image description here

jraufeisen
  • 3,005
  • 7
  • 27
  • 43
-1

Just comment the line "throw Exception('Already Initialized');"
In initialize method of vlc_player_controller.dart

Future<void> initialize() async {
    if (value.isInitialized) {
      // throw Exception('Already Initialized');
    }....
}
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 09 '22 at 16:01