Getting metadata from an audio stream

后端 未结 2 2099
攒了一身酷
攒了一身酷 2021-01-31 06:15

I would like to get the file name and, if possible, album image from a streaming URL in a AVPlayerItem that I am playing with AVQueuePlayer but I don\'t know how to go about doi

2条回答
  •  滥情空心
    2021-01-31 06:53

    When retrieving a particular item I would use the Metadata common keys constant declared in AVMetadataFormat.h, i.e.: AVMetadataCommonKeyTitle.

    NSUInteger titleIndex = [avItem.asset.commonMetadata indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
        AVMutableMetadataItem *metaItem = (AVMutableMetadataItem *)obj;
        if ([metaItem.commonKey isEqualToString:AVMetadataCommonKeyTitle]) {
            return YES;
        }
        return NO;
    }];
    
    AVMutableMetadataItem *item = [avItem.asset.commonMetadata objectAtIndex:titleIndex];
    NSString *title = (NSString *)item.value;
    

提交回复
热议问题