flutter-meedu-player icon indicating copy to clipboard operation
flutter-meedu-player copied to clipboard

I have a error when I exit full screen in ios. Systemdevice be locked landscape not change to potrait

Open gamestap99 opened this issue 4 years ago • 7 comments

gamestap99 avatar Oct 18 '20 11:10 gamestap99

When you create an instance of MeeduPlayerController you can pass the param screenManager these must be an instance of ScreenManager and define the default device orientations after close the fullscreen page.

Here and example how to allow landscape and portrait mode after exit fullscreen

    List<DeviceOrientation> orientations = [
      DeviceOrientation.portraitDown,
      DeviceOrientation.portraitUp,
      DeviceOrientation.landscapeLeft,
      DeviceOrientation.landscapeRight,
    ];

  _meeduPlayerController = MeeduPlayerController(
      screenManager: ScreenManager(
        orientations: orientations,
      ),
    );

For example if you have an smartphone you maybe only allow portrait mode but in a tablet you allow landscape and portrait.

  List<DeviceOrientation> orientations = [
      DeviceOrientation.portraitDown,
      DeviceOrientation.portraitUp,
    ];

    if (isTablet) {
      orientations.addAll([
        DeviceOrientation.landscapeLeft,
        DeviceOrientation.landscapeRight,
      ]);
    }

    _meeduPlayerController = MeeduPlayerController(
      screenManager: ScreenManager(
        orientations: orientations,
      ),
    );

darwin-morocho avatar Oct 18 '20 14:10 darwin-morocho

When you create an instance of MeeduPlayerController you can pass the param screenManager these must be an instance of ScreenManager and define the default device orientations after close the fullscreen page.

Here and example how to allow landscape and portrait mode after exit fullscreen

    List<DeviceOrientation> orientations = [
      DeviceOrientation.portraitDown,
      DeviceOrientation.portraitUp,
      DeviceOrientation.landscapeLeft,
      DeviceOrientation.landscapeRight,
    ];

  _meeduPlayerController = MeeduPlayerController(
      screenManager: ScreenManager(
        orientations: orientations,
      ),
    );

For example if you have an smartphone you maybe only allow portrait mode but in a tablet you allow landscape and portrait.

  List<DeviceOrientation> orientations = [
      DeviceOrientation.portraitDown,
      DeviceOrientation.portraitUp,
    ];

    if (isTablet) {
      orientations.addAll([
        DeviceOrientation.landscapeLeft,
        DeviceOrientation.landscapeRight,
      ]);
    }

    _meeduPlayerController = MeeduPlayerController(
      screenManager: ScreenManager(
        orientations: orientations,
      ),
    );

i try it but i not work. i have a issue and it work for me

gamestap99 avatar Oct 18 '20 16:10 gamestap99

image that

gamestap99 avatar Oct 18 '20 16:10 gamestap99

that not good because my project support only portraitup. My code before good for android and error for ios. I hope you fix proplem you soon. I really like package of you. thank for support

gamestap99 avatar Oct 18 '20 16:10 gamestap99

that not good because my project support only portraitup. My code before good for android and error for ios. I hope you fix proplem you soon. I really like package of you. thank for support

I am not sure what is the problem because you don't provide enough information. For example I need some code to reproduce the error, what versión of this library are you using, the flutter sdk versión and the ios device that you are using to test. I run the example project on my iPhone x and it works fine.

darwin-morocho avatar Oct 19 '20 03:10 darwin-morocho

that not good because my project support only portraitup. My code before good for android and error for ios. I hope you fix proplem you soon. I really like package of you. thank for support

I am not sure what is the problem because you don't provide enough information. For example I need some code to reproduce the error, what versión of this library are you using, the flutter sdk versión and the ios device that you are using to test. I run the example project on my iPhone x and it works fine.

when I exit fullscreen my device is locked in landscape view while my device only allows potraitUp. It doesn't generate an error but I don't know how it stays in landscape view, it just ends when I close the app and restart. I use the latest package and the sdk is always the newest (dart: 2.10.2 , flutter: 1.22.2)

gamestap99 avatar Oct 20 '20 08:10 gamestap99

I believe I experienced the same issue as you on iOS but after enabling landscape mode on the info.plist I was able to control the behavior.

If you wanna allow the user to go on landscape mode when on fullscreen but restore the portraitUp when is minimized, your app indeed supports landscape mode (at least on 1 screen), so you should enable that on:

info.plist image

AndroidManifest.xml already has enabled the ability to change the orientation dynamically in the mainactivity image

On your main.dart you should allow only portraitUp:

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

    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp
    ]);
  }

On your Widget, you should use @gamestap99 method to go back to portrait mode when the user minimizes it:

image

Give it a try and let me know if that works for you :)


Now, on the other hand, if your project only supports portraitUp and you wanna keep the user in portrait mode regardless of fullscreen mode, the ScreenManager has a property called forceLandScapeInFullscreen which is true by default, if you set it to false meedu player won't take you to landscape mode at all keeping the app always on portrait.

_meeduPlayerController = MeeduPlayerController(
    screenManager: ScreenManager(
        forceLandScapeInFullscreen: false,
    ),
);

Regardless of your use case, you might wanna use 'forceLandScapeInFullscreen' as follows:

_meeduPlayerController = MeeduPlayerController(
    screenManager: ScreenManager(
        forceLandScapeInFullscreen: videoAspectRatio >= 1,
    ),
);

This way, when fullscreen is tapped, portrait videos will stay on portraitUp, and landscape videos will force landscape mode.

Cheers

gabrielginter avatar Nov 07 '20 09:11 gabrielginter