Я хочу воспроизвести видео в формате UIView с помощью MPMoviePlayerController.
После нажатия кнопки UIB видео появляется и начинает воспроизводиться.
К сожалению, через 3-4 секунды видео становится черным, звук все еще воспроизводится.
Есть идеи?
Спасибо за ваше время.
(с использованием Xcode 4.2.1)
-(void) playMovieButtonPressed:(UIButton*) button{
NSString* video = @"testmovie.m4v";
NSString *filepath = [[NSBundle mainBundle] pathForResource:[video stringByDeletingPathExtension] ofType:[video pathExtension]];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController* player = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
player.movieSourceType = MPMovieSourceTypeFile;
[player.view setFrame:CGRectMake(20, 400, 300, 200)];
[self.view addSubview:player.view];
[player prepareToPlay];
[player play];
}
- (void) moviePlaybackComplete:(NSNotification*) notification {
NSLog(@"videoviewcontroller complete: %@", notification);
MPMoviePlayerController *mymoviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:mymoviePlayerController];
}