I tried this and I get a list of chapters created programmatically, but I can't make it show thumbnails.
This is the code I'm using:
CMTime time1 = CMTimeMakeWithSeconds(0, 1);
CMTime duration1 = CMTimeMakeWithSeconds(90, 1);
AVMutableMetadataItem *title1 = [[AVMutableMetadataItem alloc] init];
title1.key = AVMetadataCommonKeyTitle;
title1.keySpace = AVMetadataKeySpaceCommon;
title1.value = @"Opening";
title1.locale = NSLocale.currentLocale;
title1.time = time1;
title1.duration = duration1;
AVMutableMetadataItem *artwork1 = [[AVMutableMetadataItem alloc] init];
artwork1.key = AVMetadataCommonKeyArtwork;
artwork1.keySpace = AVMetadataKeySpaceCommon;
artwork1.dataType = (__bridge NSString * _Nullable)(kCMMetadataBaseDataType_JPEG);
artwork1.value = UIImageJPEGRepresentation([UIImage imageNamed:@"cu-pic-1"], 1);
artwork1.locale = [NSLocale currentLocale];
artwork1.time = time1;
artwork1.duration = duration1;
AVTimedMetadataGroup *chapter1 = [[AVTimedMetadataGroup alloc]
initWithItems:@[title1, artwork1]
timeRange:CMTimeRangeMake(time1, duration1)];
AVNavigationMarkersGroup *chapterGroup = [[AVNavigationMarkersGroup alloc]
initWithTitle:@"Chapters"
timedNavigationMarkers:@[chapter1]];
playerItem.navigationMarkerGroups = @[chapterGroup];
And I just get a label with the text "Opening", but no UIImageView around. I can confirm the image I use is loading and the NSData generated is correct.
http://cl.ly/image/1G0t3C1D320S
(The image you see is the same image, but provided as Artwork of the player item through the extraMetadata method)
Why aren't the thumbnails showing up? Is this a bug in the tvOS AVPlayerViewController?
Thanks in advance! 😀