我正在使用AVPlayer播放视频。我无法播放.mp4格式的视频,只看到黑屏。以下是我的代码:
`NSString *filePath = [self.videoArray objectAtIndex:index];
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:filePath ofType: @"mp4];
url = [[NSURL alloc] initFileURLWithPath: soundFilePath];
playerViewController = [[AVPlayerViewController alloc] init];
playerViewController.videoGravity = AVLayerVideoGravityResize;
playerViewController.view.frame = self.view.bounds;
playerViewController.showsPlaybackControls = NO;
video=[AVPlayer playerWithURL:url];
playerViewController.player = _video;
playerViewController.view.userInteractionEnabled = false;
[video play];
[self.view addSubview:playerViewController.view];`
NSLog
或调试点检查 filepath 或 soundFilePath 是否具有适当的值?还提供更多详细信息,例如您收到的错误日志。 - Ravi Bself.video_Array
这个数组中包含哪些URL链接,是HTTP链接还是本地链接? - Ravi B