vimeo_player icon indicating copy to clipboard operation
vimeo_player copied to clipboard

How to play video based on dynamic id ?

Open TheDev563 opened this issue 4 years ago • 2 comments

Video is not playing when I click on listview item, I have passed video id dynamic in VimeoPlayer.

TheDev563 avatar Feb 17 '21 11:02 TheDev563

@pradeep-gc Hi! Haven't you tried just using stateful widget as parent? I think it gonna work.


If you're still interested: Dynamic resource change isn't possible for VideoPlayerController which is used in vimeo_player. But you can easily set new controller with another resource. Right now i'm implementing controller support for this plugin, so later you'll be able to switch resource dynamically. I'll keep in touch when the update comes out.

ksydex avatar May 01 '21 22:05 ksydex

In my case, I did the following code. The idea here is to use key: UniqueKey() and every time when you select a video from listView the video change

  @override
  Widget build(BuildContext context) {
    return SliverToBoxAdapter(
      child: SafeArea(child: Consumer<SeccionesProvider>(
        builder: (context, seccionesProvider, _) {
          if (seccionesProvider.leccionSeleccionada.tipo != 10) {
            return LeccionWidget();
          }
          return ReproductorWidget(
            key: UniqueKey(),
            idVideo: seccionesProvider.leccionSeleccionada.idVideo,
          );
        },
      )),
    );
  }
}

class ReproductorWidget extends StatefulWidget {
  final String idVideo;
  ReproductorWidget({Key key, @required this.idVideo}) : super(key: key);

  @override
  _ReproductorWidgetState createState() => _ReproductorWidgetState();
}

class _ReproductorWidgetState extends State<ReproductorWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
        color: MarsaColors.grisOscuro,
        child: VimeoPlayer(id: widget.idVideo, autoPlay: true));
  }
}```

KitanoR avatar Jul 03 '21 16:07 KitanoR