diff --git a/src/musicbrainz/fingerprinter.cpp b/src/musicbrainz/fingerprinter.cpp index 756b4ecfe..9b05d2f34 100644 --- a/src/musicbrainz/fingerprinter.cpp +++ b/src/musicbrainz/fingerprinter.cpp @@ -32,6 +32,16 @@ Fingerprinter::~Fingerprinter() { delete event_loop_; } +bool Fingerprinter::GstreamerHasOfa() { + GstElementFactory* factory = gst_element_factory_find("ofa"); + if (!factory) { + return false; + } + + gst_object_unref(factory); + return true; +} + GstElement* Fingerprinter::CreateElement(const QString &factory_name, GstElement *bin) { GstElement* ret = gst_element_factory_make( diff --git a/src/musicbrainz/fingerprinter.h b/src/musicbrainz/fingerprinter.h index 3359d5927..9d36ba381 100644 --- a/src/musicbrainz/fingerprinter.h +++ b/src/musicbrainz/fingerprinter.h @@ -37,6 +37,9 @@ public: Fingerprinter(const QString& filename); ~Fingerprinter(); + // Checks if this gstreamer installation has the required ofa plugin. + static bool GstreamerHasOfa(); + // Creates a fingerprint from the song. This method is blocking, so you want // to call it in another thread. Returns an empty string if no fingerprint // could be created. diff --git a/src/ui/edittagdialog.cpp b/src/ui/edittagdialog.cpp index 775c5a0d7..7225dd6a2 100644 --- a/src/ui/edittagdialog.cpp +++ b/src/ui/edittagdialog.cpp @@ -23,6 +23,7 @@ #include "core/utilities.h" #include "library/library.h" #include "library/librarybackend.h" +#include "musicbrainz/fingerprinter.h" #include "playlist/playlistdelegates.h" #include "ui/albumcoverchoicecontroller.h" #include "ui/coverfromurldialog.h" @@ -59,7 +60,7 @@ EditTagDialog::EditTagDialog(QWidget* parent) connect(cover_loader_->Worker().get(), SIGNAL(ImageLoaded(quint64,QImage,QImage)), SLOT(ArtLoaded(quint64,QImage,QImage))); connect(tag_fetcher_, SIGNAL(ResultAvailable(Song, SongList)), - results_dialog_, SLOT(FetchTagFinished(Songa, SongList)), + results_dialog_, SLOT(FetchTagFinished(Song, SongList)), Qt::QueuedConnection); connect(tag_fetcher_, SIGNAL(Progress(Song,QString)), results_dialog_, SLOT(FetchTagProgress(Song,QString))); @@ -69,7 +70,6 @@ EditTagDialog::EditTagDialog(QWidget* parent) ui_->setupUi(this); ui_->splitter->setSizes(QList() << 200 << width() - 200); ui_->loading_container->hide(); - ui_->fetch_tag->setVisible(false); // An editable field is one that has a label as a buddy. The label is // important because it gets turned bold when the field is changed. @@ -679,6 +679,11 @@ void EditTagDialog::ResetPlayCounts() { } void EditTagDialog::FetchTag() { + if (!Fingerprinter::GstreamerHasOfa()) { + QMessageBox::warning(this, tr("Error"), tr("Your gstreamer installation is missing the 'ofa' plugin. This is required for automatic tag fetching. Try installing the 'gstreamer-plugins-bad' package.")); + return; + } + const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes(); SongList songs; diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 5b4ab0b64..b2fffde06 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -45,6 +45,7 @@ #include "library/librarydirectorymodel.h" #include "library/libraryfilterwidget.h" #include "library/libraryviewcontainer.h" +#include "musicbrainz/fingerprinter.h" #include "musicbrainz/tagfetcher.h" #include "playlist/playlistbackend.h" #include "playlist/playlist.h" @@ -1887,6 +1888,11 @@ void MainWindow::Exit() { } void MainWindow::AutoCompleteTags() { + if (!Fingerprinter::GstreamerHasOfa()) { + QMessageBox::warning(this, tr("Error"), tr("Your gstreamer installation is missing the 'ofa' plugin. This is required for automatic tag fetching. Try installing the 'gstreamer-plugins-bad' package.")); + return; + } + // Create the tag fetching stuff if it hasn't been already if (!tag_fetcher_) { tag_fetcher_.reset(new TagFetcher);