Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tvOS video: Title metadata truncated, artwork size too small

Tags:

ios

avplayer

tvos

I'm setting the metadata for an AVPlayer video in tvOS. The video title always gets truncated, and the artwork image is much smaller than it should be, my code is below, any ideas?

 AVMutableMetadataItem *titleMetadataItem = [[AVMutableMetadataItem alloc] init];
     titleMetadataItem.locale = NSLocale.currentLocale;
     titleMetadataItem.key = AVMetadataCommonKeyTitle;
     titleMetadataItem.keySpace = AVMetadataKeySpaceCommon;
     titleMetadataItem.identifier = AVMetadataCommonIdentifierTitle;
     titleMetadataItem.value = @"A long title that gets truncated";


     AVMutableMetadataItem *artwork1 = [[AVMutableMetadataItem alloc] init];
     artwork1.key = AVMetadataCommonKeyArtwork;
     artwork1.keySpace = AVMetadataKeySpaceCommon;
     artwork1.dataType = (__bridge NSString * _Nullable)(kCMMetadataBaseDataType_JPEG);
     UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:urlImgThumbnail]]];
     artwork1.value = UIImageJPEGRepresentation(image, .4);

     artwork1.locale = [NSLocale currentLocale];
     //

     NSArray *externalMetadata = [[NSArray alloc] initWithObjects:titleMetadataItem, artwork1, nil];

     player.currentItem.externalMetadata = externalMetadata;
like image 944
cal Avatar asked Oct 18 '22 12:10

cal


1 Answers

Currently the best solution I've been able to find to expanding the size of the metadata view is by adding a couple of \n to the description metadata item. Once the size of the metadata view increases, the image displayed will be larger. This should also prevent your title from being cut.

like image 176
David Baez Avatar answered Nov 04 '22 19:11

David Baez