Important: Please read the Qt Code of Conduct -

Need Help with GStreamer and Invalid URI in QT Multimedia

  • Hello, I am trying to create a replica of Itunes for my class. I am using taglib to get the tags of a ".mp3" file to populate my application. Also I am trying to create a player using Qtmultimedia but it seems to be giving some sort of error;
    GStreamer; Unable to pause - "/home/xtiwix/Music/Drake Feat Aaliyah - Enough Said.mp3"
    Error: "Invalid URI "/home/xtiwix/Music/Drake%20Feat%20Aaliyah%20-%20Enough%20Said.mp3"."

    I have been working on this for quite a while now, and I seem not to be able to get it right, is there any hints, help or tips that might guide me in the right path.

    here I attached the two function responsible for these tasks.
    void MainWindow::create_player()
    // Create new Media Player
    m_player = new QMediaPlayer(this);

    // Create new playlist
    m_playlist = new QMediaPlaylist(this);
    // boolean variable for functions
    m_hasSong = false;
    // Create time display of the media
    m_timedisplay = new QLCDNumber;
    // Self defined functions
    connect(m_player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
    // the m_timedisplay updater
    connect(m_player, SIGNAL(positionChanged(qint64)),this, SLOT(tick(qint64)));
    // Song Progress slider
    m_songslider = new QSlider(Qt::Horizontal, this);
    // the song progress slider updater
    connect(m_player, SIGNAL(positionChanged(qint64)),this, SLOT(progress(qint64)));
    // HBoxLayout for songslider(progress) and timedisplay(progress)
    m_songinfo_layout = new QHBoxLayout;
    // Another Layout containing buttons and songinfo layout
    m_toplayout = new QVBoxLayout;
    m_topwidget = new QWidget;
    // final product of the top layout


    void MainWindow::traverseDirs(QString path)
    QString key, val;
    QStringList list;

    // init listDirs with subdirectories of path
    QDir dir(path);
    dir.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot);
    QFileInfoList listDirs = dir.entryInfoList();
    // init listFiles with all *.mp3 files in path
    QDir files(path);
    QFileInfoList listFiles = files.entryInfoList();
    for(int i=0; i < listFiles.size(); i++)
        // init list with default values: ""
        for(int j=0; j<=COLS; j++)
            list.insert(j, "");
        // store file pathname into 0th position in list
        QFileInfo fileInfo =;
        list.replace(PATH, fileInfo.filePath());
        qDebug()  << i << "   " << fileInfo.filePath();
        QString filePathASCII = fileInfo.filePath();
        QByteArray filePatharray = filePathASCII.toLocal8Bit();
        char* filePathchar =;
                TagLib::FileRef f(filePathchar);
                TagLib::Tag *tag = f.tag();
      qDebug() << tag->genre().to8Bit(true).data();
                // process all song tags
                // Note: this uses audiere. Replace with function from Qt5 multimedia module
                for(int j=0; j<10; j++) {
                    // get tag key and value
                    key =  j;
                    val =  j;
                    if(val.isEmpty()  ) val = "Unknown";
                    // store tag value in proper position in list
                   list.replace(GENRE , tag->genre().to8Bit(true).data());
                   list.replace(ARTIST, tag->artist().to8Bit(true).data());
                   list.replace(ALBUM , tag->album().to8Bit(true).data());
                   list.replace(TITLE , tag->title().to8Bit(true).data());
                // append list (song data) into songlist m_listSongs;
                // uninitialized fields are empty strings
                m_listSongs << list;
            // base case: no more subdirectories
            if(listDirs.size() == 0) return;
            // recursively descend through all subdirectories
            for(int i=0; i<listDirs.size(); i++) {
                QFileInfo fileInfo =;
                traverseDirs( fileInfo.filePath() );
            // Populate QListWidgets and QTableWidget


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    IIRC, when passing local file to the media player, you need to use the "file://" scheme so it knows it has to look in to the file system.

    Hope it helps

  • The solution from SGaist helped me out when I had the same error messages, many thanks!