Youtube_player_flutter: Discussion: why the "videoId" is inside the controller?

Created on 4 Nov 2019  路  4Comments  路  Source: sarbagyastha/youtube_player_flutter

Hi @sarbagyastha . Yesterday I did try to use the version 6.0 but I saw that you have passed the "videoId" to the controller which I think it's not a good experience especially in my situation which I think most fo the people would say that too. in my scenario my "videoId"s are inside my list index as I'm using the listview.builder and grabbing the data from an API. so it's almost impossible to map the "videoId"s outside the listview into the controller. I'm sure you made this change for improvements but I think it's better to have the "videoId" inside the "youtubeplayer".
Thank you for this great library again.

question

All 4 comments

@Xoshbin Moved videoId to the controller in order to maintain consistency (as i'll add support for flutter web soon) and to match the behavior of YouTube IFrame Player API.

As per your issue with video lists, the solution is here.

@sarbagyastha I know I did check that too. but in my situation the video id's are inside the "listview.builder"s index so it's almost impossible to map it to the controller especially when the controller is outside the listview. I'm not sure if you understand what I say.

ListView.separated(
        itemBuilder: (context, index) {
          return YoutubePlayer(
            controller: YoutubePlayerController(initialVideoId: data[index]),
            actionsPadding: EdgeInsets.only(left: 16.0),
            bottomActions: [
              CurrentPosition(),
              SizedBox(width: 10.0),
              ProgressBar(isExpanded: true),
              SizedBox(width: 10.0),
              RemainingDuration(),
              FullScreenButton(),
            ],
          );
        },
        itemCount: data.length,
        separatorBuilder: (context, _) => SizedBox(height: 10.0),
      ),
    );

You can do like this, if you aren't using controller elsewhere.

@sarbagyastha Thanks it did work that way :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mohadel92 picture mohadel92  路  3Comments

sc00n picture sc00n  路  5Comments

channdara picture channdara  路  4Comments

jimmyff picture jimmyff  路  3Comments

kulture-rob-snider picture kulture-rob-snider  路  5Comments