问题
Is it possible to shift the system captions that display for a video should a subview (non-native, custom player controls) appear over them? The captions displayed are text WebVTT captions.
On certain screen sizes, when I shift to landscape, our custom seek bar controls overlap captions that appear at the bottom of the player.
回答1:
For what it's worth, this is possible. You need to access the AVPlayer's current item and set an AVTextStyleRule for it.
// currentPlayer is our instance of the AVPlayer
if let currItem = currentPlayer?.currentItem {
let rule = AVTextStyleRule(textMarkupAttributes: [kCMTextMarkupAttribute_OrthogonalLinePositionPercentageRelativeToWritingDirection as String: 93])
// 93% from the top of the video
currItem.textStyleRules = [rule!]
}
来源:https://stackoverflow.com/questions/39660855/shift-avplayer-captions-when-subview-overlaps-them