                 let percent = progress * 100
                 var title = NSString(format: "Loading... %.2f%%", percent)
                 if percent == 100 {
+                    videoFileReferencedURL = false
+                    let url = (self.webView.URL)
+
 					// once loaded update window title,size with video name,dimension
-					if ((self.webView.URL?.absoluteString) == nil) {
-						title = "Helium"
+					if let urlTitle = (self.webView.URL?.absoluteString) {
+                        title = urlTitle
+
+                        if ((url?.isFileReferenceURL()) != nil) {
+
+                            //	if it's a video file, get and set window content size to its dimentions
+                            if let track0 : AVAssetTrack = AVURLAsset(URL:url!, options:nil).tracks[0] {
+                                if track0.mediaType == AVMediaTypeVideo {
+                                    title = url!.lastPathComponent!
+                                    webSize = track0.naturalSize
+                                    webView.window?.setContentSize(webSize)
+									webView.bounds.size = webSize
+                                    videoFileReferencedURL = true
+                                }
+                            }
+                            
+                            //  Wait for URL to finish
+                            let videoPlayer = AVPlayer(URL: url!)
+                            let item = videoPlayer.currentItem
+                            NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(WebViewController.playerDidFinishPlaying(_:)),
+                                                                             name: AVPlayerItemDidPlayToEndTimeNotification, object: item)
+						}
 					} else {
-						let url = (self.webView.URL)
-						videoFileReferencedURL = false
-						if ((url?.isFileReferenceURL()) != nil) {
-							title = url!.lastPathComponent!
-	
-							//	if it's a video file, get and set window content size to its dimentions
-							let track0 = AVURLAsset(URL:url!, options:nil).tracks[0]
-							if track0.mediaType == AVMediaTypeVideo
-							{
-								webView.window?.setContentSize(track0.naturalSize)
-								videoFileReferencedURL = true
-							}
-
-						} else {
-							title = (url?.absoluteString)!
-						}
-					}
+                        title = "Helium"
+                    }
 					lastTitle = title as String
                 }
-                
+
                 let notif = NSNotification(name: "HeliumUpdateTitle", object: title);
                 NSNotificationCenter.defaultCenter().postNotification(notif)
             }

        }
    }
    
	var videoFileReferencedURL = false
    override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
        

    }

    var webView = WKWebView()
    var webSize = CGSize(width: 0,height: 0)
    var shouldRedirect: Bool {
        get {
            return !NSUserDefaults.standardUserDefaults().boolForKey(UserSetting.DisabledMagicURLs.userDefaultsKey)
