How to play playlist youtube video in flutter

1.2k Views Asked by At

I have playlist youtube videos list and I get id and url how to play playlist youtube videos by id or url with youtube_player_flutter I tried but not worked.

3

There are 3 best solutions below

0
On

I think you can use, better_player for this. I have used it in Android and iOs and it works well but i don't know if it works on Web.

link: https://pub.dev/packages/better_player

for playlist documentation : https://jhomlala.github.io/betterplayer/#/playlistconfiguration

0
On

you have to add youtube api to get metadata to your app. here is the link to get youtube API and get playlist : https://developers.google.com/youtube/v3/docs/playlists/list

0
On

If you are not gonna use Web, then you can use youtube_player_iframe. you dont need api.

inside State

 YoutubePlayerController _controller = YoutubePlayerController(
    initialVideoId: '1oF3pI5umck',
    params: YoutubePlayerParams(
      // Defining custom playlist
      startAt: Duration(seconds: 30),
      showControls: true,
      showFullscreenButton: true,
    ),
  );

  @override
  void dispose() {
    super.dispose();
    _controller.close();
  }

and use it like

              YoutubePlayerIFrame(
                //  gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{},
                  controller: _controller,
                  aspectRatio: 16 / 9,
                ),
              ),

here is full code: SO youtube_player_iframe