Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Local file format



  • I am slowly coming to the solution of the age-old problem of reading metadata. These are my experimental observations:

    reader is a in a istance of QMediaPlayer, and playlist is a istance of QMediaPlaylist

    If I write

    reader->setMedia(QUrl::fromLocalFile("D:/mysong.mp3"));
    

    The metadata is read correctly on the signal QMediaPlayer::LoadedMedia.

    But when I try to load the file from the playlist, the code doesn't work

    reader->setMedia((playlist->media(n)));
    

    with n a natural number

    Any suggestion?

    Thank you in advance



  • Solved

    QString mediafile = playlist->media(n).request().url().toString();
    QFileInfo fi(mediafile);
    reader->setMedia(QUrl::fromLocalFile(fi.absoluteFilePath()));