GAURAV VIG
GAURAV VIG

Reputation: 269

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. How can set the player duration in metadata?

Upvotes: 0

Views: 356

Answers (1)

ergoon
ergoon

Reputation: 1264

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

Upvotes: 0

Related Questions