fluttercommunity / chewie

The video player for Flutter with a heart of gold
MIT License
1.94k stars 1.01k forks source link

Layout when fullscreen enter and exit #160

Open zf19820621 opened 5 years ago

zf19820621 commented 5 years ago

When i toggle the video player into fullscreen model, the main page with embedded video player will be updated in landscape model, however it is designed for portrait model. It is not what i want. The code of chewie player is as follow:

Future _pushFullScreenWidget(BuildContext context) async { final isAndroid = Theme.of(context).platform == TargetPlatform.android; final TransitionRoute route = PageRouteBuilder( settings: RouteSettings(isInitialRoute: false), pageBuilder: _fullScreenRoutePageBuilder, );

SystemChrome.setEnabledSystemUIOverlays([]);
if (isAndroid) {
  SystemChrome.setPreferredOrientations([
    DeviceOrientation.landscapeLeft,
    DeviceOrientation.landscapeRight,
  ]);
}

if (!widget.controller.allowedScreenSleep) {
  Screen.keepOn(true);
}

await Navigator.of(context).push(route);
_isFullScreen = false;
widget.controller.exitFullScreen();

bool isKeptOn = await Screen.isKeptOn;
if (isKeptOn) {
  Screen.keepOn(false);
}

SystemChrome.setEnabledSystemUIOverlays(
    widget.controller.systemOverlaysAfterFullScreen);
SystemChrome.setPreferredOrientations(
    widget.controller.deviceOrientationsAfterFullScreen);

} }

I think it is more reasonable with next code order. If enter fullscreen, call push route first, then change orientation; if exit fullscreen, change orientation then pop and show main page, what do you think? My english is not well, excuse me!

zf19820621 commented 5 years ago

I have another question about 'SystemChrome.setPreferredOrientations', does it works with ios, why it is with an android judgement.

bdoubleu86 commented 5 years ago

Any chance to not change the oriantations to landscape in fullscreen on Android? I am having a portrait movie which I am playing. However in fullscreen it changes to landscape and for that reason is not using the full screen. I did set the correct aspect ratio, but of course this doesn't give a change.

bdoubleu86 commented 5 years ago

You can find a pull request to solve this issue backwards compatible.

Ahmadre commented 4 years ago

follow and raise this pr for callbacks on enter and leave: https://github.com/brianegan/chewie/pull/289