MPMoviePlayerViewController auto dismiss issue

Nearby,need to do a project about MPMoviePlayerViewController and caught a very strange issue: app

When I call  iphone

presentMoviePlayerViewControllerAnimated:
the MoviePlayerViewController can appear normally,but after 1~2 seconds,it will auto dismiss.

The original code is: ide

UITableViewCell *cell = [tableView cellForRowAtIndexPath: indexPath];
    NSString *videoPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent: cell.textLabel.text];
    NSURL *videoUrl = [NSURL URLWithString: videoPath];//different
//    NSURL *videoUrl = [NSURL fileURLWithPath: videoPath];
    
    UIGraphicsBeginImageContext(CGSizeMake(1,1));
    MPMoviePlayerViewController *playerView = [[MPMoviePlayerViewController alloc] initWithContentURL: videoUrl];
    UIGraphicsEndImageContext();
    [self presentMoviePlayerViewControllerAnimated: playerView];
    [playerView release];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(finishPlay:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
When I search for this issue,I have found many programmer has caught this issue before,but I have not found the way to fix this issue.

At last I have found the way to fix this issue,the link: this

http://stackoverflow.com/questions/8612636/iphone-mpmovieplayercontroller-dismiss-itself-before-playing-video spa

only need to change one line code,the issue can be fixed. code

It is using  orm

NSURL *videoUrl = [NSURL fileURLWithPath: videoPath];

to replace the code: server

NSURL *videoUrl = [NSURL URLWithString: videoPath];
it will be okay.

Thanks, ip

Blues string

相關文章
相關標籤/搜索