app名.app→ShowInFinder→app名→显示包内容→拖入需要播放的Mp4
#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"LoginBackground.mp4" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:videoPath];
AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:url];
_player = [AVPlayer playerWithPlayerItem:playerItem];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
playerLayer.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
playerLayer.videoGravity = AVLayerVideoGravityResizeAspect;
[v.layer addSublayer:playerLayer];
[_player play];
//添加播放完成通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(runLoopTheMovie:) name:AVPlayerItemDidPlayToEndTimeNotification object:_player.currentItem];
#pragma mark - 接收播放完成的通知
- (void)runLoopTheMovie:(NSNotification *)notification {
AVPlayerItem *playerItem = notification.object;
[playerItem seekToTime:kCMTimeZero];
[_player play];
}