Posts

Showing posts with the label AVPlayer

iOS Video Backgrounds

First things first, import the   MediaPlayer   framework: @import MediaPlayer; Next, we create a new  MPMoviePlayerController  instance within our  viewDidLoad:  method. NSURL *videoURL = [[NSBundle mainBundle] URLForResource:@"video" withExtension:@"mov"]; 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]; While we’re in  viewDidLoad: , let’s go ahead and add a notification handler to help us loop the video. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loopVideo) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer]; Time to set up that  loopVideo  function we’re calling in the above block. - (void)...