Ответ 1
1. Прежде всего добавьте MediaPlayer.Framework в XCode
2. Затем добавьте #import < MediaPlayer/MediaPlayer.h > в вашем файле viewController.h
3. Теперь реализуйте этот код в вашем методе viewDidLoad
//NSString *filepath = [[NSBundle mainBundle] pathForResource:@"aaa" ofType:@"mp4"];
//NSURL *fileURL = [NSURL fileURLWithPath:filepath];
NSURL *fileURL = [NSURL URLWithString:@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"];
moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[moviePlayerController.view setFrame:CGRectMake(0, 70, 320, 270)];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
Ориентация Пожалуйста, добавьте этот код
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
[moviePlayerController.view setFrame:CGRectMake(0, 70, 320, 270)];
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
[moviePlayerController.view setFrame:CGRectMake(0, 0, 480, 320)];
}
return YES;
}
В этом коде moviePlayerController - MPMoviePlayerController, объявленный в .h файле