Spurti Spurti - 21 days ago 6
Swift Question

How to add Launch Video for iOS app

I am trying to add Video(5 seconds) once the app launches.

I have tried to use LaunchStoryboard with AVKitPlayer, but Xcode is not allowing me to assign class for that.

class LaunchVideoViewController: UIViewController {

var playerView = AVPlayer()
var playerViewController = AVPlayerViewController()

override func viewDidLoad() {
super.viewDidLoad()

loadVideo()
}

private func loadVideo() {


let pathURL = NSURL(fileURLWithPath: "/Users/kpsbremen/Documents/KPSE1/KPSE1/launch_video.mov")
playerView = AVPlayer(URL: pathURL)

playerViewController.player = playerView


self.presentViewController(playerViewController, animated: true){
self.playerViewController.player?.play()
}

}


Please guide me.

Answer

I have one approach for this issue. Don't use launch storyboard. Just call first your viewController in which you want to run the video. As Video finishes you can move on next controller.

First -> select main storyboard.

Second -> in AppDelegate Class call the video screen. Manage the condition for these.