Open mathisxy opened 2 years ago
Actually I found a workaround:
widget.controller.addListener(() {
if (widget.controller.value.playingState == PlayingState.ended) {
widget.controller.stop().then((_) => widget.controller.play());
}
});
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...
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!
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 this works perfectly! Thanks a lot!
@mathisxy thanks for the workaround.
Was wondering if someone found a smoother solution ? There is a frame pause between stop and play.
@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);
}
});
Im unable to get any of the workarounds working. It notifies the listener, it correctly detects that the PlayingState is ended, but no matter what i do, i cant get it to start again.
I tried stop/start, i tried seeking to duration 0, tried setting _videoPlayerController.setLooping(true); but i just cant get it to work. It correctly changes the PlayingState but it just doesnt start playing again.
The only thing that works is @saddemYassin suggestion to reload the file every time you want it to loop, which is not really what i want to do...
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?