I'm trying to make a video start up alone when I opened my view however just the sound of it works. The view is blank. I'm using MPMoviePlayerController to do this.
my code is this:
@property (nonatomic, strong) MPMoviePlayerController *moviePlayer;
- (void)viewDidLoad {
[super viewDidLoad];
[self playVideo];
}
-(void)playVideo {
NSString *videoFile = [[NSBundle mainBundle] pathForResource:@"fds" ofType:@"mp4"];
self.moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:videoFile]];
[self.playerView addSubview:self.moviePlayer.view];
self.moviePlayer.fullscreen = YES;
self.moviePlayer.allowsAirPlay = YES;
[self.moviePlayer play];
}
Try moving your playVideo call to viewWillAppear