Landscape mode for video player

109 views Asked by At

I am using chewie video player in flutter. My app does not allow landscape mode. I only want to allow chewie player fullscreen to be in landscape. The chewie player is used in a screen similar to YouTube, with recommended videos under the player. I don't want the screen itself to be displayed in landscape.

Here is the relevant code where CustomVideoPlayer is a widget that encapsulates the chewie video player.

Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Flexible(
          child: CustomVideoPlayer(
            key: ValueKey(state.data.video.url),
            url: state.data.video.url,
          ),
        ),
        ListTile(),
      ],
    );
1

There are 1 answers

0
WebDesk Solution On

@Rohan Please try below solution:

Note: The Chewie video player can go into landscape mode when in fullscreen, while the rest of the app remains in portrait mode.

CustomVideoPlayer(
  onEnterFullscreen: () => SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeRight, DeviceOrientation.landscapeLeft]),
  onExitFullscreen: () => SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]),
);