VeinGuo / VGPlayer

📺 A simple iOS video player by Vein.
https://github.com/VeinGuo/VGPlayer
MIT License
400 stars 101 forks source link

Auto Re-play when video reached end. #44

Open dineshguptha opened 6 years ago

dineshguptha commented 6 years ago

Hello ,

I like this lib very much and simple to use. But how can I replay same video when it reaches to end. I mean I want to play video in infinite loop (until user stops the video).

asifbilal786 commented 6 years ago

@dineshguptha you can use below code to play video infinitely.

Implement the delegate VGPlayerDelegate and implement below method.

func vgPlayer(_ player: VGPlayer, stateDidChange state: VGPlayerState) {
        if state == .playFinished {
            player.replaceVideo((player.contentURL)!)
            player.play()
        }
    }