How to Control Presentation States

The Media Session provides transport control such as changing presentation states (Play, Pause, and Stop in a playlist-style playback scenario). This topic describes Media Session methods that an application should call to change the playback state.

The following table shows the valid presentation state transitions.

State transitionDescription
Play -> PauseThe presentation clock freezes.
Play -> StopThe presentation clock is reset.
Pause -> PlayThe presentation clock resumes from the time it froze during the Play to Pause transition.
Pause -> StopThe presentation clock is reset.
Stop -> PlayThe presentation clock starts from the beginning of the presentation.
Stop -> PauseNot allowed.


To change presentation states

  • Call the IMFMediaSession::Pause method to pause playback.

    hr = pMediaSession->Pause();

    Before calling this method, the application must call the IMFMediaSession::GetSessionCapabilities method to discover whether the media source supports the Pause state. If it does, this method returns MFSESSIONCAP_PAUSE in the pdwCaps parameter.

    Pause temporarily stops the Media Session, the presentation clock, and the stream sink for the current presentation. After the call completes successfully, the application receives a MESessionPaused event.

  • Call the IMFMediaSession::Stop method to stop playback.

    hr = pMediaSession->Stop();

    This method stops the Media Session by stopping the media source, the corresponding clocks, and stream sinks. If the Media Session is controlling the Sequencer Source, the underlying native sources are stopped by the sequencer source. After the Media Session is stopped, the application receives a MESessionStopped event.

  • Call the IMFMediaSession::Start method to start playback or seek to a new position.

    hr = pMediaSession->Start(NULL, &var);

    This method starts the Media Session from Pause and Stop states. The Media Session is responsible for setting up the data flow in the pipeline. This method instructs the Media Session to start the presentation clock. After this call, Media Session sends a MESessionStarted event to the application.

Related topics

Media Session