Bewerken

Delen via


MEBufferingStarted event

Signals that a media source has started to buffer data.

A media source can send this event if the source buffers data while the Media Session is running. When the Media Session receives this event, it pauses the presentation clock until the media source sends the MEBufferingStopped event. The Media Session also forwards the MEBufferingStarted event to the application.

Byte streams that implement the IMFByteStreamBuffering interface also send this event.

Event values

Possible values retrieved from IMFMediaEvent::GetValue include the following.

VARTYPE Description
VT_EMPTY
No event data.

Remarks

If a media source sends the MEBufferingStarted event, it must send the MEBufferingStopped event when it stops buffering data. The media source must send a matching MEBufferingStopped event for every MEBufferingStarted event. The media source should not forward these events before the source's IMFMediaSource::Start method is called, or after the source's IMFMediaSource::Stop method is called.

If you are streaming from the Media Foundation network source, you can get the buffering progress by querying the MFNETSOURCE_BUFFERPROGRESS_ID statistic. For more information, see MFNETSOURCE_STATISTICS_IDS.

Examples

HRESULT GetBufferProgress(IMFMediaSession *pSession, DWORD *pProgress)
{
    IPropertyStore *pProp = NULL;
    PROPVARIANT var;

    // Get the property store from the media session.
    HRESULT hr = MFGetService(
        pSession, 
        MFNETSOURCE_STATISTICS_SERVICE, 
        IID_PPV_ARGS(&pProp)
        );

    if (SUCCEEDED(hr))
    {
        PROPERTYKEY key;
        key.fmtid = MFNETSOURCE_STATISTICS;
        key.pid = MFNETSOURCE_BUFFERPROGRESS_ID;

        hr = pProp->GetValue(key, &var);
    }

    if (SUCCEEDED(hr))
    {
        *pProgress = var.lVal;
    }

    PropVariantClear(&var);
    SafeRelease(&pProp);
    return hr;
}

Requirements

Requirement Value
Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2008 [desktop apps only]
Header
Mfobjects.h (include Mfidl.h)

See also

Media Foundation Events

Networking in Media Foundation