简体   繁体   English

tvOS视频:如何在元数据上设置视频的持续时间

[英]tvOS video: How to set duration of video on metadata

I'm setting the title and description as metadata for an AVPlayer video in tvOS. 我将标题和描述设置为tvOS中AVPlayer视频的元数据。 How can set the player duration in metadata? 如何在元数据中设置播放器持续时间?

the info overlay should automatically display the correct duration. 信息叠加层应自动显示正确的持续时间。 if not, you can try this: 如果没有,您可以尝试以下方法:

let duration = player?.currentItem?.duration
let titleItem = AVMutableMetadataItem()

titleItem.key = AVMetadataCommonKeyTitle
titleItem.keySpace = AVMetadataKeySpaceCommon
titleItem.locale = NSLocale.currentLocale()
titleItem.value = "My Video"
titleItem.duration = duration

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM