QVariantMap TrackListDBusHandler::GetMetadata(int position) { QVariantMap ret; if (position < 0 || position > m_tracks.size()-1) { return ret; } //FIXME: ugly and slow Phonon::MediaObject mediaObject; mediaObject.setCurrentSource(m_tracks[position]); QMultiMap<QString, QString> stringMap = mediaObject.metaData(); QMultiMap<QString, QString>::const_iterator i = stringMap.constBegin(); while (i != stringMap.constEnd()) { bool number = false; int value = i.value().toInt(&number); //tracknumber always string, according to MPRIS spec if (number && (i.key().toLower() != "tracknumber")) { ret[i.key().toLower()] = value; } else { ret[i.key().toLower()] = QVariant(i.value()); } ++i; } ret["time"] = mediaObject.totalTime()/1000; ret["location"] = mediaObject.currentSource().url().toString(); return ret; }
void FindSubtitles::findSubtitles() { Phonon::MediaObject * mediaObject = quarkPlayer().currentMediaObject(); if (mediaObject) { Phonon::MediaSource source = mediaObject->currentSource(); QString fileName(source.fileName()); static FindSubtitlesWindow * findSubtitlesWindow = NULL; if (!findSubtitlesWindow) { findSubtitlesWindow = new FindSubtitlesWindow(MainWindowFactory::mainWindow()); connect(findSubtitlesWindow, SIGNAL(subtitleDownloaded(const QString &)), SLOT(loadSubtitle(const QString &))); } findSubtitlesWindow->setMovieFileName(fileName); findSubtitlesWindow->setLanguage(Config::instance().language()); findSubtitlesWindow->show(); } }