Shift AVPlayer captions when subview overlaps them

与世无争的帅哥 提交于 2019-12-22 12:18:26

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!