onEnterFullScreen method
void
onEnterFullScreen()
Implementation
void onEnterFullScreen() {
final videoWidth = widget.controller.videoPlayerController.value.size.width;
final videoHeight =
widget.controller.videoPlayerController.value.size.height;
widget.controller.setVolume(1.0);
if (widget.controller.systemOverlaysOnEnterFullScreen != null) {
/// Optional user preferred settings
SystemChrome.setEnabledSystemUIOverlays(
widget.controller.systemOverlaysOnEnterFullScreen!);
} else {
/// Default behavior
SystemChrome.setEnabledSystemUIOverlays([]);
}
if (widget.controller.deviceOrientationsOnEnterFullScreen != null) {
/// Optional user preferred settings
SystemChrome.setPreferredOrientations(
widget.controller.deviceOrientationsOnEnterFullScreen!);
} else {
final isLandscapeVideo = videoWidth > videoHeight;
final isPortraitVideo = videoWidth < videoHeight;
/// Default behavior
/// Video w > h means we force landscape
if (isLandscapeVideo) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
}
/// Video h > w means we force portrait
else if (isPortraitVideo) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
}
/// Otherwise if h == w (square video)
else {
SystemChrome.setPreferredOrientations(DeviceOrientation.values);
}
}
}