1

Problem

The widget on the next page after loading YoutubePlayerIFrame will not work.

For example, suppose you I have A and B Stateful Widgets. First A is loaded, where YoutubePlayerIFrame is called. You can press the button in A, but when you move to B, the screen freezes there.

I think this is the cause of youtube_player_iframe, but page transitions may be cause, so I will write the details.

Detail

I’m developing web app using youtube_player_iframe. I wrote the following YoutubePlayerIFrame in A StatefulWidget.

        YoutubePlayerIFrame(
          controller: YoutubePlayerController(
            initialVideoId: "NVzIALG7CUc",
            params: YoutubePlayerParams(
              showVideoAnnotations: false,
              autoPlay: false,
              startAt: Duration(seconds: 0),
              showControls: true,
              showFullscreenButton: false,
            ),
          ),
          aspectRatio: 16 / 9,
        ),

Video has displayed correctly.

Page transition

Loading other pages with this code;

runApp(MaterialApp(
 onGenerateRoute: (settings){
  Widget wid = Home();
   switch(settings.name){
     case ...........
   }

   return PageRouteBuilder(
    settings: settings,
    pageBuilder: (_, __, ___) => wid,
            transitionsBuilder: (_, a, __, c) =>
                FadeTransition(opacity: a, child: c));
)

Then call this;

  Navigator.of(context).pushReplacementNamed('/' + path);

When I remove YoutubePlayerIFrame from code, it works.

What should I do?

Beginner_
  • 645
  • 1
  • 11
  • 27

2 Answers2

0

This is not correct but when I do this, it works better.

Just paste YoutubePlayerIFrame() in all pages.

Still need answer...

Beginner_
  • 645
  • 1
  • 11
  • 27
0

I gave up to use youtube_player_iframe.

So I decided to show YouTube video with webviewx. This works better so far.

Beginner_
  • 645
  • 1
  • 11
  • 27