Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Seeking with QMediaPlayer
Qt 6.11 is out! See what's new in the release blog

Seeking with QMediaPlayer

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 5.6k 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.
  • D Offline
    D Offline
    dialingo
    wrote on last edited by
    #1

    This is not a question but a solution. I tried to play a sound file not at the beginning but with an offset of 20 seconds.

    The following fails:
    @player = new QMediaPlayer(this);
    player->setMedia(QUrl::fromLocalFile("myCoolSong.mp3"));
    player->setVolume(50);
    player->play(); // music can be heard
    qDebug() << player->isSeekable(); // is always false
    player->setPosition ( 20*1000 ); //does not work@

    It does not work because QMediaPlayer works asynchronously.
    As soon as the seek operations are delayed everything works as intended. For example:

    @CoolPlayer::on_Button1_clicked()
    {
    qDebug() << player->isSeekable(); // true
    player->setPosition ( 20*1000 );
    }@

    This should be mentioned in the documentation. For Qt we have the "fantastic new online version":http://developer.qt.nokia.com/doc/qt-4.7/ where annotations can be posted. Unfortunately Mobility is not yet integrated.

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      You could always make this into a little wiki article here on QtDevNet until such time as the mobility stuff is added to the docs here. Then you could add a docnote that links to the wiki article.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dialingo
        wrote on last edited by
        #3

        On popular request here is the article in the wiki. As a bonus it comes with a blocking setMedia() method.
        http://developer.qt.nokia.com/wiki/seek_in_sound_file

        1 Reply Last reply
        0
        • H Offline
          H Offline
          herculis
          wrote on last edited by
          #4

          could any one explain me this thing coz i also want o seek a video and i didnt get it how it works in the 2nd code which is written above
          Plz help

          1 Reply Last reply
          0

          • Login

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