我正在使用框架直接在横向模式下播放视频AVPlayerViewController
。AVKit
我想知道如何显示字幕。我进行了搜索,但没有找到任何解决方案。我MPMoviePlayerViewController
用于播放视频,但由于它在 IOS 9 及更高版本中已贬值,我正在使用AVKit
.
NSURL *videoURL = [NSURL URLWithString:video.videoLink];
AVPlayer *newPlayer = [AVPlayer playerWithURL:videoURL];
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
playerViewController.player = newPlayer;
int32_t timeScale = newPlayer.currentItem.asset.duration.timescale;
CMTime seektime=CMTimeMakeWithSeconds(startPlayBackTime, timeScale);
[playerViewController.player seekToTime:seektime toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];
}
[playerViewController.player play];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[newPlayer currentItem]];
playerViewController.player.closedCaptionDisplayEnabled = YES;
[self presentViewController:playerViewController animated:YES completion:nil];
它运行良好,但问题是我无法显示字幕。我发现很少有字幕示例,但都AVPlayer
用作子视图,所以这些方法对我不起作用。
知道如何实现这一目标吗?
谢谢 !!