How to get Video's Duration without QMediaPlayer, but with QMediaMetaData
Unsolved
General and Desktop
-
I have file .mp4 and i need to know its duration my code doesnt work
QMediaPlayer player = QMediaPlayer(this); QUrl url = QUrl(source); player.setSource(url); int duration = player.metaData().value(QMediaMetaData::Duration).toInt();
duration is Null and player.hasVideo() return false. How i can get QMediaMetaData without QMediaPlayer
-
Hi and welcome to devnet,
You need to wait for the media to be loaded before requesting metadata. I haven't tested it but the metadataChanged signal might indicated that they are now available.