Reputation: 11
I am working on an iphone app that downloads a video from a web server and then plays this video. my problem is that sometimes the server replies to me with an empty file not a valid video. how can i check that this is a valid video file before playing?
player = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlaying:) name:MPMoviePlayerPlaybackDidFinishNotification object:player];
player.controlStyle = MPMovieControlStyleFullscreen;
[player play];
Upvotes: 1
Views: 1876
Reputation: 679
You can check file size with help of NSFileManager:
NSFileManager* manager = [[NSFileManager alloc] init];
NSError* error;
NSDictionary* attributes = [manager attributesOfItemAtPath:[url path] error:&error];
int size = [attributes fileSize];
Upvotes: 1