Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get Video's Duration without QMediaPlayer, but with QMediaMetaData
Qt 6.12 LTS is out! See what's new in the release blog

How to get Video's Duration without QMediaPlayer, but with QMediaMetaData

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stupid_pupid
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved