tags:

views:

36

answers:

1

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];
A: 

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];
eviltrue
thanks it worked perfectly
belhaouary
you are welcome, don't forget to accept the answer ;)))
eviltrue