Trying to dectect when WKWebKit start loading video, to stop animation

356 Views Asked by At

I conformed to "WKNavigationDelegate" and according to the document I am using these methods, but it seems like they're not getting call. I am not getting any result.

func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
    stopAnimating()

    print("didStart Video is loading...")
}

func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
    stopAnimating()

    print("Video is loading...")
}

Complete Code, anyhelp in the right direction would help, Thanks!

override func viewDidAppear(_ animated: Bool) {
    NVActivityIndicatorView.DEFAULT_BLOCKER_SIZE = CGSize(width: 35, height: 35)
    startAnimating(message:"Loading...", type: .lineScale, color: .lightGray)

    guard let url = holdUrl else {return}

    if let url = URL(string:url) {
        let request = URLRequest(url: url)
        myWebView.load(request)
        myWebView.scrollView.isScrollEnabled = false
    }
1

There are 1 best solutions below

0
Iam Wayne On

Adding "myWebView.navigationDelegate = self" fixed my problem...