loopsmediaplaybackfoundation

How to implement loop playback using IMFSequenceSource as a playlist in a video player written with Media Foundation?


I called function SkipTo(0) after I received MESessionEnded media session event,the function Invoke outputed the following events in sequence: MESessionCapabilitiesChanged,MESessionStarted,MEEndOfPresentationSegment,MESessionTopologySet and MESessionTopologyStatus media session events. BUT the Window didn't display video .

Why ?How to implement loop playback?

PLEASE tell me!!!

HRESULT CPlaylist::SkipTo(DWORD index)
{
    if (index >= segmentCount)
    {
        return E_INVALIDARG;
    }

    MFSequencerElementId ID = segments[index].SegmentID;

    PROPVARIANT var;

    String debugStr(">>>>Segment ID is:"+IntToStr((int)ID) );
    OutputDebugString(debugStr.w_str());
    HRESULT hr = MFCreateSequencerSegmentOffset(ID, 0, &var);

    if (SUCCEEDED(hr))
    {
        hr = mediaSession->Start(&MF_TIME_FORMAT_SEGMENT_OFFSET, &var);
        PropVariantClear(&var);
    }
    return hr;
}

I expected that the vide display the window like first play.


Solution

  • I solved this problem myself:

    HRESULT hr = m_pSequencerSource->AppendTopology(
    pTopology,
    0,//SequencerTopologyFlags_Last,
    &SegmentId
    

    );

    Do not pass the parameter "SequencerTopologyFlags_Last", the SkipTo function will work well