0

Is there a way to change the Youtube flutter Flags after first init.

I am trying to make it so that upon clicking a button to a new video it changes video and then also sets the Flags startAt and endAt to my chosen ints.

However controller.flags.startAt and the end at come up with the error "can't be used as a setter because it's final.

_ytController = YoutubePlayerController(
        initialVideoId: YoutubePlayer.convertUrlToId(defaultStream)!,
        flags: const YoutubePlayerFlags(
          mute: false,
          loop: true,
          autoPlay: true,
        ));
        
        
        _ytController.startAt = 20; //doesn't allow due to final
        _ytController.endAt = 30;
Ankere
  • 13
  • 4

2 Answers2

0

You can pass them within the YoutubePlayerController inside of a YoutubePlayerParams() object. Set it after you set flags to something like this:

flags: const YoutubePlayerFlags(...),
params: YoutubePlayerParams(startAt: 20, endAt: 30)
Jet.B.Pope
  • 642
  • 1
  • 5
  • 25
  • This is for a different Package. Im using Youtube_player. This seems to be for Youtube_player_iframe. Also, i want to be able to put a variable in the startAt and endAt field and when the new video is player for it to start and end at those times. – Ankere Oct 27 '22 at 11:38
  • No, it's for youtube_player_flutter. I'm not seeing any published packages for youtube_player, so I suspect you're also using this package. Also, just replace the numbers with your variables and you're good. – Jet.B.Pope Oct 27 '22 at 13:28
0

I found it. You use the controller.Load and within there after you put in the YoutubePlayer.convertUrlToId(url) then you can set your start and End time.

Ankere
  • 13
  • 4