Activity monitor replaced by video on XCODE 10

I want to replace activity monitor(animation) with .mov video(instead of animation) that plays before loading the app, and while other tabs are also being loaded

Tried the method of "import AVFountdation" and "AVKit" but I am new to XCODE I cant figure out how to do it properly - I can play Video

I also have managed to use "activity monitor" - works fine while website loads, now i want to merge both code together i get the below code for reference.


import UIKit
import WebKit
import AVFoundation
import AVKit

class ViewController: UIViewController {

    @IBOutlet weak var videoView: UIView! /* I want to play as my "activity monitor" - instead of the circle loading animation
    @IBOutlet weak var webView: WKWebView! /* when this loads video will "hide"

    override func viewDidLoad() {
        // Do any additional setup after loading the view, typically from a nib.



    override func didReceiveMemoryWarning() {
        // Do any resources that can be recreated.

        let url = ""
        let request = URLRequest(url: URL(string: url)!)

        self.webView.addObserver(self, forKeyPath: #keyPath(WKWebView.isLoading), options: .new, context: nil)


    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {

        if keyPath == "loading" {

            if webView.isLoading {

                activityIndicator.isHidden = false

            }else {

                activityIndicator.isHidden = true

     if webView.isLoading {

                private func setupView() {
            let path = URL(fileURLWithPath: Bundle.main.path(forResource: "quicksilverhd", ofType: "mov")!)
            let player = AVPlayer(url: path)

            let newLayer = AVPlayerLayer(player: player)
            newLayer.frame = self.videoView.frame
            newLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill

            player.actionAtItemEnd = AVPlayer.ActionAtItemEnd.none

            NotificationCenter.default.addObserver(self, selector: #selector(ViewController.videoPlayerDidPlayToEnd(_:)), name: NSNotification.Name(rawValue: "AVPlayerItemDidPlayToEndTimeNotification"), object: player.currentItem)


        @objc func videoPlayerDidPlayToEnd(_ notification: Notification) {
            let player: AVPlayerItem = notification.object as! AVPlayerItem

   = false

    }else {
   = true        }