Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pause/play any video using Button #5

Open
bhutvijay204 opened this issue Mar 13, 2019 · 4 comments
Open

How to pause/play any video using Button #5

bhutvijay204 opened this issue Mar 13, 2019 · 4 comments

Comments

@bhutvijay204
Copy link

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

@Goldy-74
Copy link

@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
Copy link

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
Copy link

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

@kuldeep13990
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants