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?
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?
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 displayedf 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)),
],
),
)
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');
}....
}