ian
ian

Reputation: 1002

How do URL's work for files

I'm using Parse to download my PFFiles for my videos and images on my backend. However after i get the file url from the PFFile, it takes forever to load. Why is this? Does using a file url mean you are essentially downloading the data? Like the PFFile was just a network pointer to the actual image/videos?

NSURL *fileUrl = [NSURL URLWithString:scene.file.url];
AVAsset *asset1 = [AVAsset assetWithURL:fileUrl];
AVPlayerItem *item = [[AVPlayerItem alloc] initWithAsset:asset1];
[QPlayer insertItem:item afterItem:nil];

If this is true, Would a NSURLCache allow me to save THAT DATA locally without having to say go to this server via this url to get THAT DATA?

Essentially I'm asking am I downloading this twice - the PFFILE then the data its contents point to? And if so would an NSCache allow me to only do the second download once?

Thanks! I'm trying to really get the conceptual understanding of networking.

Upvotes: 1

Views: 114

Answers (1)

danh
danh

Reputation: 62676

The OP code as presented does just one synchronous download. But if it got the scene object from parse just before, then there are two network operations, both necessary, as you point out.

You can cache whatever you wish in an NSCache.

The file download is probably slow because the file is large. And it must feel very slow because the synchronous operation -- if done on the main -- blocks the UI.

Upvotes: 1

Related Questions