Я пытаюсь воспроизвести видео на одном из моих экранов.Кажется, он работает, но когда файл открывается, полноэкранный загружается и закрывается сразу после.Видео длится несколько секунд и имеет формат m4v.Я добавил фреймворк и импортировал класс.Как сделать так, чтобы видео воспроизводилось нормально?
Мой заголовок:
-(IBAction)playMedia:(id)sender {
NSString *movieFile;
MPMoviePlayerController *moviePlayer;
movieFile = [[NSBundle mainBundle]
pathForResource:@"movie" ofType:@"m4v"];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL: [NSURL fileURLWithPath: movieFile]];
[moviePlayer.view setFrame:CGRectMake(145.0, 20.0, 155.0 , 100.0)];
[self.view addSubview:moviePlayer.view ];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playMediaFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[moviePlayer play];
if ([toggleFullscreen isOn]) {
[moviePlayer setFullscreen:YES animated:YES];
}
}
Мой файл реализации:
-(void)playMediaFinished: (NSNotification*)theNotfication {
MPMoviePlayerController *moviePlayer=[theNotfication object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[moviePlayer.view removeFromSuperview];
[moviePlayer release];
}
спасибо