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
415 stars 76 forks source link

functionality to pause or play the current story #63

Closed Arun30sep closed 5 years ago

Arun30sep commented 5 years ago

I would like to request the feature to pause and play again from the point where it is paused in the stories section i.e. IGStoryPreviewController

Currently I'm not able to select pause the story when preforming specific actions like share. If it is already in the library. Please let me know what I can use.

boominadhaprakash commented 5 years ago

Hi @Arun30sep

In IGStoryPreviewCell, you can find the longPressGesture code. You can use the same code for pause and play again. I think that code will be apt for your requirement.

@objc private func didLongPress(_ sender: UILongPressGestureRecognizer) {
        if sender.state == .began || sender.state == .ended {
            let v = getProgressView(with: snapIndex)
            let videoView = scrollview.subviews.filter{v in v.tag == snapIndex + snapViewTagIndicator}.first as? IGPlayerView
            if sender.state == .began {
                if videoView != nil {
                    v?.pause()
                    videoView?.pause()
                }else {
                    v?.pause()
                }
            }else {
                if videoView != nil {
                    v?.resume()
                    videoView?.play()
                }else {
                    v?.resume()
                }
            }
        }
    }

You can find the above same code in IGStoryPreviewCell. Please use the same for your requirement. Let us know, if it's not works properly or you struggle to add that code for your requirement.