How to get the current playback position ?

Hi all,

Is anyone know how to get the current playback position

Regards,

lka



Answer this question

How to get the current playback position ?

  • migz148

    Hi Becky Weiss,

    Thanks for the reply.

    It helps albeit a bit harder for DirectShow developers who get used to the IMediaPostion and IMediaSeeking interfaces way of getting the current position. If IMFClock::GetCorrelatedTime(...) method is the way to get the current position, how about rateless media sinks, it's still applicable

    Thanks,

    lka


  • RussP

    In Media Foundation, the current playback position is available from the clock at IMFMediaSession::GetClock(). This clock gives you presentation time.

    For single-topology playback (like playing a single media file, no sequences or any other IMFMediaSession::SetTopology calls), presentation time is usually going to be the time that an application would want to display in its UI as "current position".

    To get this right in general (when more than one topology is being played), you need to be aware of the fact that when MF moves from playing topology1 to topology2, the presentation time keeps moving up continuously; it does not reset for topology2. Applications, however, usually want to display what we call "source time", which means resetting the displayed time for topology2. To help with translating presentation time to source time, the Media Session will send an MESessionNotifyPresentationTime event. This event carries two important pieces of data:

    • MF_EVENT_START_PRESENTATION_TIME. This gives you a presentation time (will usually be in the near future) at which this notification will become effective
    • MF_EVENT_PRESENTATION_TIME_OFFSET. This is the offset that will help you translate presentation time into source time. Your computation will look like this: SourceTime = PresentationTime - PresentationTimeOffset, where PresentationTime is what you read off the presentation clock, and PresentationTimeOffset is the value of this attribute.

    Hope that helps!



  • Ashok Ojha

    Since Media Foundation is a v1 platform, it doesn't provide the same amount of high-level support that DShow does (stuff like IMediaPosition, etc); the application has to do a few more steps by hand.

    Rateless sinks work exactly the same way: Just get the time off the clock.



  • MarlAtkins

    Thanks Becky !
  • How to get the current playback position ?