开发者

QT Movie Metadata Tagging with QTKit

I'm trying to d开发者_StackOverflowo some metadata tagging to some video files using QTKit. I've got things down for tagging atom that take a string as their value, but having a hard time setting atoms that take an 8-bit integer as their argument. Here is what I got right now from Apple's Documentation and other various sources on the internet:

-(void) setMediaKind: (NSString *) value
{
QTMetaDataRef   metaDataRef;
Movie           theMovie;
OSStatus        status;

theMovie = [movie quickTimeMovie];
status = QTCopyMovieMetaData (theMovie, &metaDataRef );
NSAssert(status == noErr,@"QTCopyMovieMetaData failed!");

if (status == noErr)
{
    int intValue = NSSwapHostIntToBig([(NSNumber *)value intValue]);
    UInt8 *dataValuePtr = (UInt8*)(&intValue);
    ByteCount dataSize = sizeof(int);

    if (dataValuePtr)
    {
        OSType key = 'stik';
        QTMetaDataItem outItem;
        status = QTMetaDataAddItem(metaDataRef,
                                   kQTMetaDataStorageFormatiTunes, 
                                   kQTMetaDataKeyFormatiTunesShortForm,
                                   (const UInt8 *)&key,
                                   sizeof(key),
                                   dataValuePtr,
                                   dataSize,
                                   kQTMetaDataTypeSignedIntegerBE,
                                   &outItem);
        NSAssert(status == noErr,@"QTMetaDataAddItem failed!");

        char langCodeStr[] = "en";
        status = QTMetaDataSetItemProperty(
                                           metaDataRef,
                                           outItem,
                                           kPropertyClass_MetaDataItem,
                                           kQTMetaDataItemPropertyID_Locale,
                                           strlen(langCodeStr) + 1,
                                           langCodeStr);
    }
}
}

So the atom 'stik' sets the video's kind in iTunes. If I want to specify the video as a TV Show i'd need to assign it a value of 10. If I send @"10" to this method I don't get any errors but the video file isn't properly tagged either.

I'm sure part of my problem is I skipped learning C and went straight to Objective C so when I have to dive into C like this I have problems.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜