     }
     
     func resourceLoader(resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool {
-    
         if self.connection == nil {
             debug("Starting request to get media URL: \(self.mediaURL)")
             let request = NSURLRequest(URL: replaceUrlScheme(loadingRequest.request.URL!, scheme: "http")!)
-            self.connection = NSURLConnection(request: request, delegate: self, startImmediately: false)
-            self.connection?.setDelegateQueue(NSOperationQueue.mainQueue())
-            self.connection?.start()
+            self.connection = session.dataTaskWithRequest(request)
+            self.connection?.resume()
         }
         
         self.pendingRequests.append(loadingRequest)

        }
        assert(self._asset != nil, "Asset should not be nil")
    }
    
    func connection(connection: NSURLConnection, didReceiveResponse response: NSURLResponse) {
        self.data = NSMutableData()
        self.response = response
        self.processPendingRequests()
    }
    
    func connection(connection: NSURLConnection, didReceiveData data: NSData) {
        self.data?.appendData(data)
        self.processPendingRequests()
    }
    
    func connection(connection: NSURLConnection, didFailWithError error: NSError) {
        print(error)
    }
    
    func connectionDidFinishLoading(connection: NSURLConnection) {
        self.processPendingRequests()
        debug("Writing data to local cached file: \(self.cachePath!)")
        do {
            try self.data?.writeToFile(self.cachePath!, options: NSDataWritingOptions.AtomicWrite)
        } catch {
            debug("Unable to write to original file")
        }
    }
    
    func processPendingRequests() {
        self.pendingRequests = self.pendingRequests.filter { loadingRequest in
            self.fillInContentInformation(loadingRequest.contentInformationRequest)

        self.cachePath      = cachePath
        self.cachingEnabled = cachingEnabled == nil ? false : cachingEnabled!
        super.init()

        let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
        configuration.allowsCellularAccess = true
        configuration.timeoutIntervalForRequest = 30
        self.session = NSURLSession(configuration: configuration, delegate: self, delegateQueue: NSOperationQueue.mainQueue())
    }
    
    var asset: AVURLAsset {
