I am using the following code to show a full-screen video on my UIView:
- (void)playMovie:(NSString *)name :(NSString *)type
{
NSURL *movieURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:name ofType:type]];
self.movieAsset = [AVAsset assetWithURL:movieURL];
self.movieItem = [[AVPlayerItem alloc] initWithAsset:self.movieAsset];
self.moviePlayer = [[AVPlayer alloc] initWithPlayerItem:self.movieItem];
self.moviePlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
self.movieLayer.videoGravity = AVLayerVideoGravityResize;
self.movieLayer = [AVPlayerLayer playerLayerWithPlayer:self.moviePlayer];
[self.movieLayer setFrame:self.view.frame];
[self.view.layer addSublayer:self.movieLayer];
[self.moviePlayer addObserver:self forKeyPath:@"status" options:0 context:nil];
// Schedule stop after 6 seconds
[NSTimer scheduledTimerWithTimeInterval:6.0 target:self selector:@selector(stopCurrentMovie:) userInfo:nil repeats:NO];
}
The video is playing, but it doesn't fill (stretch if needed) the entire screen, but it only resizes maintaining its width/height ratio: I have tried all the three values of "videoGravity"... nothing seems to change.
How can I solve? Thank you