Bill
Bill

Reputation: 125

objective c load AVAsset from NSFileManager file path

So i download an .mp4 file using

urlData * =[NSData dataWithContentsOfUrl:filePath]

then save it using NSFileManager

[urlData writeToFile:filePath atomically:YES];

this saves the file in the NSFileManager directory just fine I can go into iTunes and see it, open and play the video so I know that part is working.

Here is where it breaks for me. I want to open and play these files, so i use like i use

[AVURLAsset URLAssetWithURL:filePath options:nil];

for some reason this always goes to a state of 'AVPlayerStatusFailed'. When I put a break point in and inspect the error I get 'unknown error'

Error Domain=NSURLErrorDomain Code=-1 "unknown error" UserInfo={NSLocalizedDescription=unknown error, NSUnderlyingError=0x1382f9630 {Error Domain=NSOSStatusErrorDomain Code=-12935 "(null)"}}

what am i missing here? or how can i get a better error than 'unknown error'

Upvotes: 3

Views: 1968

Answers (1)

Bill
Bill

Reputation: 125

ok so as it turns out here is how i should have built the NSURL

[AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:filePath] options:nil];

Upvotes: 2

Related Questions