Shift Avplayer Captions When Subview Overlaps Them

Shift AVPlayer captions when subview overlaps them

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

How to remove the live text from an AVPlayer

You can disable it by using a special flag allowsVideoFrameAnalysis developer.apple.com

let player = AVPlayer(url: url)
let playerViewController = AVPlayerViewController()
playerViewController.player = player

if #available(iOS 16.0, *) {
playerViewController.allowsVideoFrameAnalysis = false
}


Related Topics



Leave a reply



Submit