当子视图重叠字幕时,移动AVPlayer字幕 [英] Shift AVPlayer captions when subview overlaps them

查看:56
本文介绍了当子视图重叠字幕时,移动AVPlayer字幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果子视图(非本机,自定义播放器控件)出现在视频上,是否可以转换显示的系统字幕?显示的标题是文本WebVTT标题.

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.

推荐答案

对于它的价值,这是可能的.您需要访问AVPlayer的当前项目并为其设置一个AVTextStyleRule.

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]
}

这篇关于当子视图重叠字幕时,移动AVPlayer字幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆