我想为avplayer添加字幕。我正在关注来自https://github.com/autresphere/ASBPlayerSubtitling的readMe。
@property (strong, nonatomic) IBOutlet ASBPlayerScrubbing *scrubbing;
@property (strong, nonatomic) IBOutlet ASBPlayerSubtitling *subtitling;
//我在故事板中添加了两个新对象,我将其与链接擦除和字幕
相关联AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:url options:nil];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:avAsset];
self.avPlayer = [AVPlayer playerWithPlayerItem:playerItem];
self.avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
[self.playerView.layer insertSublayer:self.avPlayerLayer atIndex:1];
self.scrubbing.player = _avPlayer;
NSURL *subtitlesURL = [NSURL URLWithString:@"file:///Users/astha/Downloads/OrangeIsTheNewBlack.srt"];
self.subtitling.player = self.avPlayer;
NSError *error = nil;
[self.subtitling loadSubtitlesAtURL:subtitlesURL error:&error];
NSLog(@"-Error: %@",error); //Error printed is nil
self.subtitling.containerView.layer.borderColor = [UIColor redColor].CGColor;
[self.playerView addSubview:self.subtitling.containerView];
视频播放得很好,但我无法看到字幕。有谁能指出我正确的方向?