Я пытаюсь создать приложение с моим видео для воспроизведения в представлении с помощью UIButton. К вашему сведению: я использую раскадровку с контроллером представления панели вкладок, поэтому этот код MPMoviePlayerView находится внутри другого представления.
Я продолжаю получать эту ошибку: * Завершение работы приложения из-за необработанного исключения "NSInvalidArgumentException", причина: "* -[NSURL initFileURLWithPath:]: нулевой строковый параметр"
Вот мой код:
VideoTefViewController.h
#import <UIKit/UIKit.h>
@interface VideoTefViewController : UIViewController
-(IBAction)playMovie;
@end
VideoTefViewController.m
#import "VideoTefViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@interface VideoTefViewController ()
@end
@implementation VideoTefViewController
-(IBAction)playMovie {
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"tef" ofType:@"mp4"];
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
[theMovie play];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end