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

Changing metadata of a .mp3 file using QMediaPlayer?



  • I have a simple app where I load .mp3 file and display its metadata in a QTableView. I see it works pretty well. This is how I get the metadata and its value

    QStringList metadataList = m_player->availableMetaData();
    QVariant value = m_player->metaData(data);
    

    What I want now is to edit the metadata value in my table view column and save it back in the .mp3.

    QMediaObject has a metadata changed signal but I am not sure when and how it is emitted.

    Did I miss any setMetadata(QString value) in QMediaPlayer?

    Is it even possible to edit and save the metadata back to .mp3? If yes, how?



  • @MarKS

    Have a look at QMetaDataWriterControl. It has setMetaData.

    This whole class is deprecated, but it shows, that it's definitely possible to do in Qt... but I can't say what to use instead.



  • @Pl45m4 thanks! This is a good find. The documentation states it is obsolete but didn't mention any alternatives. Does it mean they removed this feature from QtMultimedia?



  • @MarKS

    Don't know :)
    Haven't used it myself, so I can't say more.

    Can't imagine that they remove features completely. There might be another class that does something similar or there are other workarounds.

    Unfortunately the Qt Documentation doesn't always tell what to use instead when there is an obsolete class.



  • As you can see from the doc, QMetaDataWriterControl is an abstract class, most of its functions are virtual.
    It is just an interface class and the functions need to be implemented by the media plugins.
    And from Qt Multimedia Backends you can see that "MetaData writer" is not a feature of media player, but recording. And it is only supported by the GStreamer plugin on Unix platform.
    There's QMediaRecorder::setMetaData(...) which would probably try to use this interface internally. So it's not for QMediaPlayer I think.


Log in to reply