flutter_vlc_player icon indicating copy to clipboard operation
flutter_vlc_player copied to clipboard

Looping not working

Open mathisxy opened this issue 2 years ago • 8 comments

The video always stops at the (isLooping true or false) and I cant even workaround by invoking play() on the controller, because then just nothing happens.

Is this a common bug or should I give more details?

mathisxy avatar Jul 16 '22 13:07 mathisxy

Actually I found a workaround:

widget.controller.addListener(() {

      if (widget.controller.value.playingState == PlayingState.ended) {

        widget.controller.stop().then((_) => widget.controller.play());

      }

    });

mathisxy avatar Jul 16 '22 13:07 mathisxy

I have experienced this as well.. nothing I do can make the video able to restart, and adding this Ended/Stop/Play thing worked. Thank you. But also, this seems like a bug. Or I am deeply misunderstanding something.

My flutter pub deps shows this info about flutter_vlc_player: |-- flutter_vlc_player 7.1.5 | |-- flutter... | |-- flutter_vlc_player_platform_interface 2.0.1 | | |-- flutter... | | |-- meta... | | '-- plugin_platform_interface... | '-- meta...

CJP-work-acct avatar Oct 19 '22 23:10 CJP-work-acct

Hello @mathisxy ! could you provide an example of your workaround? I don't quite understand how to implement it and how it should looks.

Thank you!

pmoraru avatar Apr 21 '23 06:04 pmoraru

Hallo @pmoraru !

I think this should work as a minimal example. I didnt test it, so please tell me if there is something not working.

class VlcWrapper extends StatefulWidget {
  const VlcWrapper(this.controller, {Key? key}) : super(key: key);

  final VlcPlayerController controller;

  @override
  State<VlcWrapper> createState() => _VlcWrapperState();
}

class _VlcWrapperState extends State<VlcWrapper> {

  @override
  void initState() {

    widget.controller.addListener(() {
      if(widget.controller.value.playingState == PlayingState.ended)  { // if video has ended
        widget.controller.stop().then((_) => widget.controller.play()); // stop (reset) the video and play again after stop completed
      }
    });

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return VlcPlayer(controller: widget.controller, aspectRatio: 1);
  }
}

Usage: VlcWrapper(VlcPlayerController.xxx)

mathisxy avatar Apr 21 '23 08:04 mathisxy

@mathisxy this works perfectly! Thanks a lot!

pmoraru avatar Apr 21 '23 08:04 pmoraru

@mathisxy thanks for the workaround.

Was wondering if someone found a smoother solution ? There is a frame pause between stop and play.

JohannDesobry avatar Jul 12 '23 09:07 JohannDesobry

@mathisxy The best way to do that I found and work for me is to the set the some data source when it end playing

controller!.addListener(() {
          if (controller!.value.playingState == PlayingState.ended) {
            controller!.setMediaFromFile(file, autoPlay: false, hwAcc: HwAcc.auto);
          }
});

saddemYassin avatar Feb 08 '24 13:02 saddemYassin