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

isMetaDataAvailable() isn'twork..



  • So i'm basically working on a music player and i have a line of code that checks if a music file has metadata associated with it so it can get some data of the music file but it doesn't work and the issue is that isMetaDataAvailable() evaluates to false even when the music file has metadata. As you can see i used an application to check if the music file has metadata and it does so why does isMetaDataAvailable() evaluate to false
    24c553c8-ccf2-4ee4-8a4d-7cc9ab327542-image.png
    Here is the code:
    9b3676e4-507a-4928-869c-cfadcfe16814-image.png


  • Lifetime Qt Champion

    @Padawan From https://doc.qt.io/qt-5/qmediaplayer.html#setMedia :
    "Note: This function returns immediately after recording the specified source of the media. It does not wait for the media to finish loading and does not check for errors. Listen for the mediaStatusChanged() and error() signals to be notified when the media is loaded and when an error occurs during loading.".
    I suggest you call isMetaDataAvailable in a slot connected to mediaStatusChanged().


  • Lifetime Qt Champion

    @Padawan From https://doc.qt.io/qt-5/qmediaplayer.html#setMedia :
    "Note: This function returns immediately after recording the specified source of the media. It does not wait for the media to finish loading and does not check for errors. Listen for the mediaStatusChanged() and error() signals to be notified when the media is loaded and when an error occurs during loading.".
    I suggest you call isMetaDataAvailable in a slot connected to mediaStatusChanged().



  • @jsulm thanks, it worked, i made a slot that connects to that signal and checks if the media is in a BufferedMedia State and it works fine now



  • For anyone wanting to know, i connected a slot function to the mediaStatusChanged() signal and the function checks if it's in a BufferedMedia state which would mean it would have finished loading the media fully and it would possess the metadata(if the media has one) and it works as i intended now;
    447274a2-40f2-4574-b678-c8eb9e87d7ed-image.png
    87fd7588-8fe1-4b6d-becf-9a470da7ef76-image.png
    afc45c2c-cee2-43fc-8374-43a65d84f520-image.png


Log in to reply