drawRect / Instagram_Stories

Inspired by Instagram Stories functionality. This source is similar to Instagram Stories, which is having both image and video support.
MIT License
414 stars 76 forks source link

Handpick index is not getting 0 #145

Open niravpadhiyar09 opened 5 months ago

niravpadhiyar09 commented 5 months ago

When the data in this form like 1st user have 2 videos , 2nd user have 1 video then if you move to 3rd user then story in not playing because the handpickindex and snap index is not match

private func startPlayer(videoView: IGPlayerView, with url: String) {
    if scrollview.subviews.count > 0 {
        if story?.isCompletelyVisible == true {
            videoView.startAnimating()
            IGVideoCacheManager.shared.getFile(for: url) { [weak self] (result) in
                guard let strongSelf = self else { return }
                switch result {
                    case .success(let videoURL):
                        /// Start progressor only if handpickedSnapIndex matches with snapIndex
                        if(strongSelf.handpickedSnapIndex == strongSelf.snapIndex) {
                            let videoResource = VideoResource(filePath: videoURL.absoluteString)
                            videoView.play(with: videoResource)
                    }
                    case .failure(let error):
                        videoView.stopAnimating()
                        debugPrint("Video error: \(error)")
                }
            }
        }
    }
}

I share one json file try to play all story from this file

https://github.com/drawRect/Instagram_Stories/assets/68903203/1aa99966-f7a9-4ecb-b6e0-1bfad99f57a0

stories.json