I upload the video and save it in some directory so that the user can then play this file.
It works well in all cases, for example, when the download stops and resumes again due to some network fluctuations. But sometimes the file is fully loaded, but not played in MPMoviePlayerViewController.
I am using ASIHTTPRequest to download video files in the background.
Observation. It may be that the network hesitates several times during startup, and the file may be corrupted.
Question. How to find out if the downloaded file is damaged? (via MPMoviePlayerViewControll)
Any suggestions? Below is the code:
@ACB ... I used your code, but it always goes into a different state:
playerViewController = [[MPMoviePlayerViewController alloc]initWithContentURL:url]; player = [playerViewController moviePlayer]; player.movieSourceType = MPMovieSourceTypeFile; [player prepareToPlay]; if(player.loadState == MPMovieLoadStatePlayable) { playerViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentMoviePlayerViewControllerAnimated:playerViewController]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerInterruptByUser:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:playerViewController.moviePlayer]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:playerViewController.moviePlayer]; //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerFinished:) name:UIApplicationDidEnterBackgroundNotification object:playerViewController.moviePlayer]; [player play]; } else { corruptVideoAlert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"Corrupt Video", nil) message:NSLocalizedString(@"This video is corrupted due to some network error. We suggest you to download again. Do you want to download it again?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil),nil]; [corruptVideoAlert show]; [corruptVideoAlert release]; }
source share