initService method

Future<void> initService({
  1. int startIndex = 0,
})

Implementation

Future<void> initService({int startIndex = 0}) async {
  await addVideosController();
  int myindex = startIndex;

  try {
    if (!videoPlayerControllerList[myindex].value.isInitialized) {
      cacheVideo(myindex);
      await videoPlayerControllerList[myindex].initialize();
      increasePage(myindex + 1);
    }
  } catch (e) {
    log('Error initializing video at index $myindex: $e');
  }

  animationController.repeat();
  videoPlayerControllerList[myindex].play();
  refreshView();
  // listenEvents(myindex);
  await initNearByVideos(myindex);
  loading.value = false;

  Future.delayed(Duration.zero, () {
    pageController.jumpToPage(myindex);
  });
}