Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-97152

QMediaPlayer 'play' jumps to wrong position after seek

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 6.2.0
    • Fix Version/s: 6.2.1, 6.2, 6.3.0 Alpha
    • Component/s: Multimedia
    • Labels:
      None
    • Environment:
      Windows 10
      Qt 6.2
    • Platform/s:
      Windows
    • Commits:
      9285ad4a87c47d2744124f14aebe710e1ee55517 (qt/qtmultimedia/dev) ade14c3b2db9fe5e03e12c3052f0c6ead77b1481 (qt/qtmultimedia/6.2)

      Description

      Summary

      As per attached code, using QMediaPlayer and (in my case) QVideoWidget:

      • Start app and video autoplays
      • Pause at e.g. 3s
      • setPosition(0.5s)
      • Play

      EXPECTED: Video plays from setPosition location i.e. 0.5s

      ACTUAL: Video plays from pause position i.e. 3s - visually it jerks forward.

       

      Further Details from MFPlayerSession.cpp

      When a IMFMediaSession pause() completes, the callback MFPlayerSession::handleSessionEvent caches the current WMF clock time as m_position:

      case MESessionPaused:        
          m_position = position() * 10000;
      

      Clearly, this would allow a consecutive start() to resume at m_position which makes sense.

      If instead, setPosition() is called after pause(), a slightly different situation arises. setPositionInternal() calls setScrub(true) which correctly sets the frame rate to 0 and flags a scrub as taking place (m_scrubbing=true).

      However, when start() is called the following happens (elided):

      if (m_scrubbing)
                  scrub(false);
        //...elided     
      PROPVARIANT varStart;        
      InitPropVariantFromInt64(m_position, &varStart);
      if (SUCCEEDED(m_session->Start(&GUID_NULL, &varStart))) { 
      //...}
      

       
      Thus start() always resumes from the cached m_position.

      Perhaps, after turning off scrubbing state, start() could somehow adjust the cached m_position to the seek location:

      if (m_scrubbing) {
          set m_position to current seek position. Possibly using 'm_state.start'?
          scrub(false)
      }
        //...elided     
      PROPVARIANT varStart;        
      InitPropVariantFromInt64(m_position, &varStart);
      if (SUCCEEDED(m_session->Start(&GUID_NULL, &varStart))) { 
      //...}
      

      Then it would resume playback from wherever the seek ended.

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              anrocha André De La Rocha
              Reporter:
              nct Naveen Thakur
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes