Skip to content

How to change itemcount of Gridview without play vlc player again #42

Description

@Marcus-Ospicon

Hi everyone,

I am using the vlc player to show multiple videos in a GridView, it works fine however I have a small problem when changing the itemcount of gridview, if the vlc player is stopping it would automatically play again. I want to keep the playingState when changing the itemCount.

Here is my code

Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomPadding: false,
      backgroundColor: Theme.of(context).primaryColor,
      appBar: appBarLayout(context),
      body: ChangeNotifierProvider<MenuCameraViewModel>.value(
        value: _viewModel,
        child: Consumer<MenuCameraViewModel>(
          builder: (context, model, _) => GridView.builder(
            itemCount: model.getItemCount() + 1,
            padding: EdgeInsets.all(5),
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: model.viewMode ? 1 : 2,
              childAspectRatio: 16 / 11,
            ),
            itemBuilder: (context, int index) {
              return GestureDetector(
                child: Container(
                  margin: EdgeInsets.all(5),
                  color: Colors.black.withOpacity(0.5),
                  child: VlcPlayer(
                    aspectRatio: 16 / 9,
                    url: model.getUrl(index),
                    controller: model.getController(index),
                    placeholder: Center(child: CircularProgressIndicator()),
                  ),
                ),
                onTap: () {
                  model.tap(index);
                },
              );
            },
          ),
        ),
      ),
    );
  }

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions