Important: Please read the Qt Code of Conduct -

Alternative to taglib.dll

  • I hope this is the right section. I created an audio player with the Qt libraries. Since the native library QMediaPlayer does not has a function to calculate the length of the currently not reproduced media, I have resorted to using the taglib.dll library. Is there anything better

  • Maybe you don't need third-party library after all (this will depend on your app requirements).

    Here is possible solution:

    Instantiate one 'QMediaPlayer' object that will be used for playback, and another one (or more) that will be used for querying media duration and metadata of file(s) that are not playing currently.

    Note that you can't get access to this information immediately after you set media with 'QMediaPlayer::setMedia' method, you will need to create some slots and connect them to the appropriate 'QMediaPlayer' signals.
    For duration (and possibly some other info's) create one slot and connect him to the 'QMediaPlayer::mediaStatusChanged' signal and when media status changes to 'QMediaPlayer::LoadedMedia' you should be able to obtain duration.
    For metadata create another slot and connect him to the 'QMediaPlayer::metaDataAvailableChanged' signal and when metadata is available you can check what metadata is available with 'QMediaObject::availableMetaData' and than obtain metadata that you are interested in with 'QMediaObject::metaData' method.

  • I followed your instructions, , and I found the bug. Playlist is stored to, e.g., playlist.m3u file. The .m3u lines are in the form


    Calling "reader" the instance of QMediaPlayer used to receive data, through the command


    The file path becomes


    So QMediaPlayer can not find the file

  • Try:


    instead of:


  • QFile inputFile("playlist.m3u");
        if (
           QTextStream in(&inputFile);
           while (!in.atEnd())
               qDebug() << reader->duration();

    returns 0 :(

  • Since you posted only the code I can only guess that now your 'reader' object finds the file but returns duration of -1. If that is the case I suggest that you read my first post more carefully, if this is not the case describe the current issue.

  • @UnitScan if you are still heaving trouble with this take a look at

Log in to reply