Perhaps you have noticed one of the latest trend in iOS-apps: Using videos as backgrounds - mainly at login- or \"first launch\" screens. Yesterday I attempted to mimic this
I found this code on GitHub that worked for me in iOS8/9
- (void)viewDidLoad {
[super viewDidLoad];
// Load the video from the app bundle.
NSURL *videoURL = [[NSBundle mainBundle] URLForResource:@"video" withExtension:@"mov"];
// Create and configure the movie player.
self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
self.moviePlayer.controlStyle = MPMovieControlStyleNone;
self.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
self.moviePlayer.view.frame = self.view.frame;
[self.view insertSubview:self.moviePlayer.view atIndex:0];
[self.moviePlayer play];
// Loop video.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loopVideo) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];
}
- (void)loopVideo {
[self.moviePlayer play];
}