seel-channel / video_viewer

FLUTTER PACKAGE: Multiplatform minimalist video viewer with spectacular user experience.
https://pub.dev/packages/video_viewer
MIT License
56 stars 57 forks source link

IOS - App remains in landscape mode after getting back or clicking on the full screen button to minimize the player. #46

Closed MohamadSobhy closed 2 years ago

MohamadSobhy commented 2 years ago

Hi,

As you can see in the attached video, The app remains in Landscape mode after clicking on the "full screen" button to get back and see the video in the normal view. The app should back to Portrait mode again. This issue is happening only in iOS.

https://user-images.githubusercontent.com/31019449/147064957-25077349-1e37-4a9e-826b-e9ccca93e84f.mov

Any solution for this?

MohamadSobhy commented 2 years ago

I did this workaround and it fixes the issue for me.

bool _isFullScreen = false;

  @override
  void initState() {
    super.initState();

    controller.addListener(_listenToFullScreenChanges);
  }

  @override
  void dispose() {
    controller.removeListener(_listenToFullScreenChanges);
    controller.dispose();
    super.dispose();
  }

  void _listenToFullScreenChanges() {
    if (_isFullScreen != controller.isFullScreen) {
      _isFullScreen = controller.isFullScreen;
      log('isFullScreen: $_isFullScreen');

      if (!_isFullScreen) {
        // reverting the screen back to portrait mode.
        SystemChrome.setPreferredOrientations(
            [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
      }
    }
  }
seel-channel commented 2 years ago

Cool :)