Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Need Help with GStreamer and Invalid URI in QT Multimedia

Need Help with GStreamer and Invalid URI in QT Multimedia

Scheduled Pinned Locked Moved General and Desktop
qtmultimediataglibtagsgstreamer
3 Posts 3 Posters 3.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xtiwix
    wrote on 26 Apr 2015, 17:48 last edited by
    #1

    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);
    
    m_playlist->setPlaybackMode(QMediaPlaylist::Loop);
    
    // boolean variable for functions
    m_hasSong = false;
    
    // Create time display of the media
    m_timedisplay = new QLCDNumber;
    m_timedisplay->display("00:00");
    
    // 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;
    m_songinfo_layout->addWidget(m_songslider);
    m_songinfo_layout->addWidget(m_timedisplay);
    
    // Another Layout containing buttons and songinfo layout
    m_toplayout = new QVBoxLayout;
    m_topwidget = new QWidget;
    m_toplayout->addLayout(m_switchingbutton_layout);
    m_toplayout->addLayout(m_songinfo_layout);
    
    // final product of the top layout
    m_topwidget->setLayout(m_toplayout);
    

    }

    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);
    files.setFilter(QDir::Files);
    files.setNameFilters(QStringList("*.mp3"));
    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 = listFiles.at(i);
        list.replace(PATH, fileInfo.filePath());
    
        qDebug()  << i << "   " << fileInfo.filePath();
    
        QString filePathASCII = fileInfo.filePath();
    
        QByteArray filePatharray = filePathASCII.toLocal8Bit();
        char* filePathchar = filePatharray.data();
    
    
                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 = listDirs.at(i);
                traverseDirs( fileInfo.filePath() );
            }
    
            // Populate QListWidgets and QTableWidget
            populateListWidgets(m_listSongs);
            populateTableWidget(m_listSongs);
            return;
    

    }

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 26 Apr 2015, 19:44 last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      5
      • B Offline
        B Offline
        Bob van de Vijver
        wrote on 4 Nov 2016, 10:35 last edited by
        #3

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

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved