Simple question I can\'t seem to find an answer to for some reason.
How do you loop AVPlayer in Swift?
numberOfLoops = -1 only works for AVAudioPlayer
<
OK I have worked it out. Thanks Msencenb for pointing me in the right direction with an Objective C answer.
player_1?.actionAtItemEnd = .None
//set a listener for when the video ends
NSNotificationCenter.defaultCenter().addObserver(self,
selector: "restartVideoFromBeginning",
name: AVPlayerItemDidPlayToEndTimeNotification,
object: player_1?.currentItem)
//function to restart the video
func restartVideoFromBeginning() {
//create a CMTime for zero seconds so we can go back to the beginning
let seconds : Int64 = 0
let preferredTimeScale : Int32 = 1
let seekTime : CMTime = CMTimeMake(seconds, preferredTimeScale)
player_1!.seekToTime(seekTime)
player_1!.play()
}