Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

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

Open
gamestap99 opened this issue Oct 18, 2020 · 7 comments

Comments

@gamestap99
Copy link

No description provided.

@darwin-morocho
Copy link
Owner

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,
      ),
    );

@gamestap99
Copy link
Author

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
Copy link
Author

image
that

@gamestap99
Copy link
Author

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

@darwin-morocho
Copy link
Owner

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.

@gamestap99
Copy link
Author

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)

@gabrielginter
Copy link

gabrielginter commented Nov 7, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants