How to create a MetadataExtract object?


#1

Hi,

In Android, I’ve been trying to extract metadata from an MP3 audio file using a Metadata Extractor object. But I’ve been failing on create the metadataExtractorObj. This is my following code:



    SLresult result;
    // Creating engine
    result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
    assert(SL_RESULT_SUCCESS == result);
    (void)result;

    result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
    assert(SL_RESULT_SUCCESS == result);
    (void)result;

    result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
    assert(SL_RESULT_SUCCESS == result);
    (void)result;

    // Creating URI with protocol file://
    SLDataLocator_URI loc_uri = {SL_DATALOCATOR_URI, (SLchar * ) uri};
    SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, (SLchar * )"audio/mpeg3", SL_CONTAINERTYPE_MP3};
    SLDataSource audioSrc = {&loc_uri, &format_mime};

    // Creating URI with protocol
    SLObjectItf metadataExtactCreatorObj = NULL;
    const SLInterfaceID ids[1] = {SL_IID_METADATAEXTRACTION};
    const SLboolean req[1] = {SL_BOOLEAN_FALSE};
//    const SLInterfaceID ids[] = {};
//    const SLboolean req[] = {};

    result = (*engineEngine)->CreateMetadataExtractor(engineEngine
            ,&metadataExtactCreatorObj 
            ,&audioSrc
            ,1
            ,ids
            ,req);

//    assert(SL_RESULT_SUCCESS == result);
//    (void)result;
    if (SL_RESULT_FEATURE_UNSUPPORTED == result) // <----- The result is always Feature Unsupported
    {
        return;
    }

    result = (*metadataExtactCreatorObj)->Realize(metadataExtactCreatorObj, SL_BOOLEAN_FALSE);
    assert(SL_RESULT_SUCCESS == result);
    (void)result;

    SLMetadataExtractionItf metadataExtractionItf;
    result = (*metadataExtactCreatorObj)->GetInterface(metadataExtactCreatorObj, SL_IID_METADATAEXTRACTION, &metadataExtractionItf);
    assert(SL_RESULT_SUCCESS == result);
    (void)result;


The result that I always get from CreateMetadataExtractor is SL_RESULT_FEATURE_UNSUPPORTED. What am I missing for this to be SL_RESULT_SUCCESS?

Thanks you, have a nice day. :slight_smile:


#2

Hi Chaq686,

If you are getting the result code SL_RESULT_FEATURE_UNSUPPORTED, that means that the implementation does not support CreateMetadataExtractor(). The problem isn’t in your code, it’s the lack of support for metadata by the implementation.

Best,

Erik