How to keep the video resolution fixed in youtube video player in flutter?

1.3k Views Asked by At

I want to fix the video resolution to 240p manually in code. But how can I do it? And how does actually playbackQuality work? Whenever I use playbackQuality, it does not show any properties. Is it to fix the video quality? I did not find any solution.

class _VideoScreenState extends State<VideoScreen> {
  YoutubePlayerController _controller;

  String _videoId = YoutubePlayer.convertUrlToId(
      'https://www.youtube.com/watch?v=YE7VzlLtp-4');

  @override
  void initState() {
    super.initState();
    YoutubePlayerValue(
      playbackRate: PlaybackRate.normal,
    );
    _controller = YoutubePlayerController(
      initialVideoId: _videoId,
      flags: YoutubePlayerFlags(
        loop: true,
        autoPlay: true,
        forceHD: false,
        enableCaption: false,
        hideControls: true,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'Youtube Video Player',
          style: TextStyle(
              color: Colors.blueAccent,
              fontSize: 22.0,
              fontWeight: FontWeight.bold),
        ),
        backgroundColor: Colors.white,
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.symmetric(horizontal: 12.0),
        child: YoutubePlayer(
          controller: _controller,
          aspectRatio: 16 / 9,
          onReady: () {
            print('The Video ID : $_videoId');
          },
        ),
      ),
    );
  }
} 
1

There are 1 best solutions below

1
On

According to an issue on youtube_player_flutter's repository, it is not possible to change the quality.