youtube_player_flutter icon indicating copy to clipboard operation
youtube_player_flutter copied to clipboard

[BUG] Youtube stop playing video when change to Full Screen mode

Open ixsans opened this issue 4 years ago • 9 comments

When i am playing youtube in portrait mode then change it to full screen (landscape) mode, the video get paused instead of continue playing the video.

How To Reproduce

  1. Play video in portrait mode
  2. Click full screen button during playing video
  3. Video stopped

Expected behavior

  1. Play video in portrait mode
  2. Click full screen button during playing video
  3. Video continuing from previous state

ixsans avatar Aug 22 '20 07:08 ixsans

+1

ChopinDavid avatar Aug 25 '20 16:08 ChopinDavid

+1

MrJohn2014 avatar Aug 25 '20 18:08 MrJohn2014

It is not a bug really.

Add this to the initialization code:

youtubePlayerController.onEnterFullscreen = () {
        SystemChrome.setPreferredOrientations([
          DeviceOrientation.landscapeLeft,
          DeviceOrientation.landscapeRight,
        ]);
      };

      youtubePlayerController.onExitFullscreen = () {
        SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
        Future.delayed(const Duration(seconds: 1), () {
          youtubePlayerController.play();
        });
        Future.delayed(const Duration(seconds: 5), () {
          SystemChrome.setPreferredOrientations(DeviceOrientation.values);
        });
      };

YazeedAlKhalaf avatar Aug 26 '20 17:08 YazeedAlKhalaf

It is not a bug really.

Add this to the initialization code:

youtubePlayerController.onEnterFullscreen = () {
        SystemChrome.setPreferredOrientations([
          DeviceOrientation.landscapeLeft,
          DeviceOrientation.landscapeRight,
        ]);
      };

      youtubePlayerController.onExitFullscreen = () {
        SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
        Future.delayed(const Duration(seconds: 1), () {
          youtubePlayerController.play();
        });
        Future.delayed(const Duration(seconds: 5), () {
          SystemChrome.setPreferredOrientations(DeviceOrientation.values);
        });
      };

I tried on my end. When enter the full screen mode, video is replayed from the beginning. How could video played from the previous state? Should I add some listener or how could I implement that?

MrJohn2014 avatar Aug 27 '20 13:08 MrJohn2014

facing the same issue. I am guessing a callback is not being returned properly

ComputelessComputer avatar Feb 21 '21 08:02 ComputelessComputer

Well...

It is not a bug really.

Add this to the initialization code:

youtubePlayerController.onEnterFullscreen = () {
        SystemChrome.setPreferredOrientations([
          DeviceOrientation.landscapeLeft,
          DeviceOrientation.landscapeRight,
        ]);
      };

      youtubePlayerController.onExitFullscreen = () {
        SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
        Future.delayed(const Duration(seconds: 1), () {
          youtubePlayerController.play();
        });
        Future.delayed(const Duration(seconds: 5), () {
          SystemChrome.setPreferredOrientations(DeviceOrientation.values);
        });
      };

You're sure, what isn't bug? Cause i want continue playing video from the same moment when i open full-screen and vice versa.

But if video is canceled and i change my orientation, it's start again.

Not an expected behavior. So?..

AshereLoker avatar Aug 11 '21 09:08 AshereLoker

Is this fixed yet? Any workaround?

singh-karan-7 avatar Dec 21 '21 08:12 singh-karan-7

I am facing the same issue.

when i change to landscape the video gets stopped and when i try to play the video, its start from the begining.

Senthuran-01 avatar May 08 '22 10:05 Senthuran-01

its written in the docs

For FullScreen Support
If fullscreen support is required, wrap your player with YoutubePlayerBuilder

YoutubePlayerBuilder(
    player: YoutubePlayer(
        controller: _controller,
    ),
    builder: (context, player){
        return Column(
            children: [
                // some widgets
                player,
                //some other widgets
            ],
        );
    ),
),

I have tried this. it work seamlessly and video keep playing

devinyonas avatar Jul 05 '22 08:07 devinyonas

its written in the docs

For FullScreen Support
If fullscreen support is required, wrap your player with YoutubePlayerBuilder

YoutubePlayerBuilder(
    player: YoutubePlayer(
        controller: _controller,
    ),
    builder: (context, player){
        return Column(
            children: [
                // some widgets
                player,
                //some other widgets
            ],
        );
    ),
),

I have tried this. it work seamlessly and video keep playing

I am using this and it works when going to full screen, it keeps playing on the same moment. However, when I exit full screen it stops playing, and the controller returns to the initialVideo. Any clue on how to solve this?

pbayog00 avatar Apr 24 '23 10:04 pbayog00