AutoVideoPlayer icon indicating copy to clipboard operation
AutoVideoPlayer copied to clipboard

How to pause/play any video using Button

Open bhutvijay204 opened this issue 5 years ago • 4 comments

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

bhutvijay204 avatar Mar 13 '19 13:03 bhutvijay204

@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()

Goldy-74 avatar Jun 14 '19 04:06 Goldy-74

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.

hamzaaminx avatar Mar 11 '20 09:03 hamzaaminx

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

pratikgajbhiye222 avatar Jul 16 '20 06:07 pratikgajbhiye222

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

kuldeep13990 avatar Oct 06 '22 06:10 kuldeep13990