获取最后显示的WebVTT提示

时间:2017-11-26 16:46:00

标签: ios

假设我正在使用HTTP直播(HLS)和使用WebVTT字幕在我的应用中显示视频。这就是我的代码应该是这样的(我没有尝试过,因为我没有适当的后端)

try! composition.insertTimeRange(CMTimeRangeMake(kCMTimeZero, videoAsset.duration), ofAsset: videoAsset, atTime: kCMTimeZero)  
        let subtitleTrack = composition.addMutableTrackWithMediaType(AVMediaTypeSubtitle, preferredTrackID: CMPersistentTrackID(kCMPersistentTrackID_Invalid))  
        try! subtitleTrack.insertTimeRange(CMTimeRangeMake(kCMTimeZero, subtitleAsset.duration), ofTrack: subtitleAsset.tracks[0], atTime: kCMTimeZero)  
        let playerVC = AVPlayerViewController()  
        presentViewController(playerVC, animated: false, completion: nil)  
        playerVC.player = AVPlayer(playerItem: AVPlayerItem(asset: composition))  
        playerVC.player!.play()

除了在视频上显示字幕外,应用程序是否可以获取用户最后显示的字幕字符串或服务器上最后一次显示的字幕字符串?像这样的东西

While(playing){
let lastSubtitle = playerVC.player.lastDisplayedSubtitle();
print(lastSubtitle); // print the last displayed subtitle on the console
}

0 个答案:

没有答案