Bagikan melalui


MediaStreamSource.ReportGetSampleCompleted Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Developers call this method in response to GetSampleAsync to give the MediaElement the next media sample to be rendered, or to report the end of a stream.

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Protected Sub ReportGetSampleCompleted ( _
    mediaStreamSample As MediaStreamSample _
)
protected void ReportGetSampleCompleted(
    MediaStreamSample mediaStreamSample
)

Parameters

Exceptions

Exception Condition
ArgumentException

The MediaStreamSource is not setup for protected playback and the DRMAlgorithmID on the sample is set, then an exception is thrown for all cases except when the DRMAlgorithmID is equal to "Unprotected".

ArgumentException

The MediaStreamSample is not setup for protected playback and the DRMKeyIdentifier on the sample is set, then an exception is thrown for all cases except when the Guid is equal to Guid.Empty.

ArgumentException

The value of the DRMKeyIdentifier attribute in the input MediaStreamSample parameter is set to Guid.Empty.

Or the following conditions are true:

Remarks

This method should be called after a request to GetSampleAsync unless ErrorOccurred was called instead. ReportGetSampleProgress could be called before this to indicate that a sample is not ready yet but this method must eventually be called.

If the MediaStreamSample contains a valid Stream object, Silverlight will seek the stream’s pointer to the specified offset. When this method returns, the specified count of bytes will have been read, and the current position of the stream will have advanced past those bytes.

To report the end of a stream, construct a MediaStreamSample object with a null stream and pass it into ReportGetSampleCompleted. Reporting the end of a stream lets the MediaElement know that no additional samples for that stream will be available. Once the MediaElement has rendered all possible samples for all streams, it automatically transition into the Paused or Stopped state and raise a MediaEnded event.

State Transitions: Calling ReportGetSampleCompleted on any stream indicates buffering is complete for the media and retracts permissions to be in the Buffering state. If the MediaElement is in the Buffering state, the call to this method will cause it to transition back to the Playing state.

When ReportGetSampleCompleted returns, the underlying video codec no longer holds any ownership to the memory pointed to by the MediaStreamSample which was passed in. Depending on your implementation, that memory may now be considered ready for recycling or disposal at any point after the call has been made.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.