ashish0309 / AutoVideoPlayer

Easily Play/Pause videos in any UIView subclass especially UITableViewCell subclass
MIT License
101 stars 17 forks source link

How to pause/play any video using Button #5

Open bhutvijay204 opened 5 years ago

bhutvijay204 commented 5 years ago

I am using ASVideoPlayerController but this auto play but how to use play and push using button

Goldy-74 commented 5 years ago

@bhutvijay204 Hope this helps

Add this in ASVideoPlayerController class

var shouldPlay : Bool = false {
    didSet{
        self.currentVideoContainer()?.shouldPlay = shouldPlay
    }
}

then and in ASVideoContainer class add following lines of code

var shouldPlay : Bool = false {
    didSet{
        if shouldPlay {
            player.play()
        } else {
            player.pause()
        }
    }
}

Now just simply call from your desired action for pause and play as

ASVideoPlayerController.sharedVideoPlayer.shouldPlay.toggle()

hamzaaminx commented 4 years ago

Hi. Great library for auto playing videos in table view cell. I wanted to pause/play videos on didSelectRowAt and applied this code but it is not working fine. It is having following issues.

  1. It does not pause video first time. Pauses the video when tapped twice.
  2. On scrollViewDidEndDecelerating it starts playing the paused video.

Any help would be appreciated. Did you achieve this @bhutvijay204 . @Goldy-74 Any idea how to solve this. Thanks in advance.

pratikgajbhiye222 commented 4 years ago

I want to play and pause the video on the tap on video? @hamzaaminx Did you Achieve this

kuldeep13990 commented 1 year ago

Hi @Goldy-74 Thanks for your answer. Could you please let us know how can we show the progress while video is buffering?