我曾尝试在后台视图中播放mp4视频..但此代码工作正常并在模拟器和iPhone 6及6+中提供结果 但是当我将它运行到iPhone 5或与这些屏幕设备相关时......视频无法播放或运行..
我正在使用此代码:
NSString *filepath1 = [[NSBundle mainBundle] pathForResource:@"login" ofType:@"mp4"];
NSURL *fileURL1 = [NSURL fileURLWithPath:filepath1];
vwVideoBg.backgroundColor = [UIColor blackColor];
self.avPlayerItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:filepath1]];
//AVPlayer *avPlayer = [[AVPlayer playerWithURL:[NSURL URLWithString:url]] retain];
self.avPlayer = [AVPlayer playerWithPlayerItem:self.avPlayerItem];
AVPlayerLayer *avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
NSLog(@"%@",filepath1);
avPlayerLayer.frame = self.view.frame;
[vwVideoBg.layer addSublayer:avPlayerLayer];
//[self.view addSubview:vwVideoBg];
[self.avPlayer play];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;