Search code examples
qtqmediaplayer

How to get type of media in QMediaPlayer (video or audio)?


I want to draw image in video widget when video is not playing. But I don't know how to check if media is not video. The problem is that source file extension can be mp3, but it is video.

QMediaPlayer::isVideoAvailable doesn't work for me.


Solution

  • I had the same problem and I've solved by checking

    QMediaPlayer::isVideoAvailable()
    

    But, as in your case, it may not work if checked too early.

    To be sure, you should connect to the signal:

    QMediaPlayer::videoAvailableChanged(bool videoAvailable)
    

    And then show the image if videoAvailable == false.