Closed RzTutul closed 1 year ago
Hey, @RzTutul are you using PageView?
@khanmujeeb687 Yes i used PageView
Okay, So what happens is when you swipe to a page in pageview it builds at that moment, and initState gets called at that moment that's why it takes time to initialize the video. One top-rated solution for this issue is to load the next page before when we are on the previous page. Flutter Pageview I think does not support this functionality. So we can achieve it using this plugin: https://pub.dev/packages/preload_page_view. This is the same as pageview but you can pass the count of pages you want to preload.
@khanmujeeb687 I tried PreLoadPageView but It is playing all the videos at the same time. Also, it is not disposing of the video controller of the previous page while scrolling to the next page. Could you please help me out with this?
@override Widget build(BuildContext context) { return new PreloadPageView.builder( itemCount: ..., itemBuilder: ..., onPageChanged: (int position) {...}, ..... preloadPagesCount: 3, controller: PreloadPageController(), ); }
Hey @RzTutul , Since you have set the preloadPagesCount to 3 so it will keep the current , previous and next page loaded. If you want only the current video to play then maybe you can set the videos to pause by default or maybe you can find some other workaround for that.
If you are familiar with provider and already using it in your project for state management. Then you can store the currentVideoId in a variable and add a listener to it, so when it changes so depending upon the ID you can play and pause the video.
I am trying to build video reels like Instagram or TikTok. I used appinio_video_player 1.2.0 but when I swap a new video then it takes time to initialize. I initialized the controller at initState. can you resolve this?