Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

New Contributor
Posts: 5
Registered: ‎08-19-2011
My Device: Blackberry Bold 9000
My Carrier: Claro

Problem reading audio metadata



I'm trying to use the media player in C++ iterating from a list of music track names in order to get their metadata (title, duration, album, etc).  My problem is that if I'm iterating 4 files, for example, I will get around 10 objects (I return a QList of an object I'm populating with the information on a processingCompleted signal. 

I'm new (very new) to C++, Qt, Cascades in general, so after taking the online video courses at the Blackberry developer website and reading the online documentation (and lots of internet searches) I was able to come up with the code below:



//Here I receive a list of the selected files


void TrackMetadataReader:Smiley TonguerocessTracks(QString basedirectory, QStringList selectedFiles)

for (int i=0;i<selectedFiles.count(); i++) {
QString fullFilePath = basedirectory + "/" + selectedFiles.at(i);

emit tracksProcessingCompleted(_TrackInfos);


//Here I'm using an QEventLoop in order to have the function "wait" until the trackInfoCompleted signal has been emited, which I do on the onMetaDataChanged slot


void TrackMetadataReader:Smiley TonguerocessTrackInfo(QString fileLocation)
QEventLoop loop;

loop.connect(this, SIGNAL(trackInfoCompleted(TrackInfo*)), &loop, SLOT(quit()));
bool ct = connect(m_mp, SIGNAL(metaDataChanged(const QVariantMap&)), this, SLOT(onMetaDataChanged(const QVariantMap&)), Qt:Smiley Very HappyirectConnection);
bb::multimedia::MediaError::Type mediaError = m_mp->prepare();




void TrackMetadataReader:Smiley SurprisednMetaDataChanged(const QVariantMap& metaData)

if (m_mp->mediaState()==bb::multimedia::MediaState:Smiley Tonguerepared) {

QString trackName = metaData[bb::multimedia::MetaData&colon;:Title].toString();
int trackDuration = metaData[bb::multimedia::MetaData&colon;Smiley Very Happyuration].toInt();

m_track = new TrackInfo();
TrackInfo *track;

emit trackInfoCompleted(m_track);


//Then, on the calling class I have a tracksProcessingCompleted slot. I always get more items than processed

(some empty items and others repeated several times).


void TrackManager:Smiley SurprisednTracksProcessingCompleted(QList<TrackInfo *> TrackInfos)
int tracksCount = TrackInfos.count();


So obviously I'm doing something wrong, but I've been at this for 3 days and haven't been able to figure out what I'm missing.

Anyone have any idea?


Thanks in advanced.