// ----------------------------------------------------------------------------------------------------------
// Filter out media in aMediaArray which match aFilter
// ----------------------------------------------------------------------------------------------------------
//
void CTestCollectionPlugin::FilterMediaArray(CMPXMediaArray& aMediaArray, CMPXFilter* aFilter)
{
    if(aFilter )
    {
        TArray<TMPXAttribute> filterAttr = aFilter->Attributes();
        TInt arrCnt = aMediaArray.Count();
        for(TInt i = arrCnt-1; i >= 0; i--) // Remove from the back
        {
            CMPXMedia* media = aMediaArray[i];
            for(TInt ii = 0; ii < filterAttr.Count(); ii++)
            {
                TMPXAttribute attr = filterAttr[ii];
                if( media->IsSupported( attr ) )
                {
                    TBool match = EFalse;
                    if(attr == KMPXMediaGeneralId)
                    {
                        TInt filterId = *aFilter->Value<TInt>( attr );
                        TInt mediaId = *media->Value<TInt>( attr );
                        if(filterId == mediaId)
                            match = ETrue;
                    }
                    else if(attr == KMPXMediaGeneralTitle || attr == KMPXMediaGeneralUri)
                    {
                        const TDesC& filterText = aFilter->ValueText( attr );
                        const TDesC& mediaText = media->ValueText( attr );
                        if(filterText == mediaText)
                            match = ETrue;
                    }
                    if( match )
                    {
                        aMediaArray.Remove( i );
                        break;
                    }
                }
            }
        }
    }
}