You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wrestled with this for longer than I'd like to admit. Turns out background videos do not loop by default and none of the examples I found worked. The eventual solution was below (leaving the ? off moviePlayerController will throw an unexpected nil error):
Some type of .shouldLoopVideo = true/false would be a nice feature!
Wrestled with this for longer than I'd like to admit. Turns out background videos do not loop by default and none of the examples I found worked. The eventual solution was below (leaving the ? off moviePlayerController will throw an unexpected nil error):
Some type of .shouldLoopVideo = true/false would be a nice feature!
let vc = OnboardingViewController(backgroundVideoURL: generateVideo(file: "engineBackground"), contents: [firstPage, secondPage, thirdPage])!
vc.shouldBlurBackground = false
vc.shouldFadeTransitions = true
vc.swipingEnabled = true
NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: vc.moviePlayerController?.player?.currentItem, queue: nil, using: { (_) in
DispatchQueue.main.async {
vc.moviePlayerController?.player?.seek(to: kCMTimeZero)
vc.moviePlayerController?.player?.play()
}
})
static private func generateVideo(file: String) -> URL {
let bundle = Bundle.main
let moviePath = bundle.path(forResource: file, ofType: "mp4")
let movieURL = URL(fileURLWithPath: moviePath!)
return movieURL
}
The text was updated successfully, but these errors were encountered: