This topic has not yet been rated - Rate this topic

MediaStreamSource.ReportGetSampleCompleted Method

Silverlight

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)
protected void ReportGetSampleCompleted(
	MediaStreamSample mediaStreamSample
)

Parameters

mediaStreamSample
Type: System.Windows.Media.MediaStreamSample
The description of the media stream that this sample came from. Passing a MediaStreamSample object with a null Stream property indicates that the stream has ended.
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:

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.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

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

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

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Thanks for the comment
Thanks a lot for your comment, I faced the same problem. The documentation is wrong, you can't pass a null. If you have Resharper you can know this while coding, Resharper send a warning saying that you're passing a null parameter to a method marked to not accept null..
Thanks again !
(and please MS correct the doc !)
Passing null to this method results in NullReferenceException
Everything's working well, but when I reach the end of my data and I want to end it. According to the documentation, I must call this method with a null parameter.

This causes a NullReferenceException to be thrown. What am I doing wrong?

Update: I just realized the problem. If you want to indicate that the stream is ended, you don't pass a null parameter to this method. You pass a MediaStreamSample with a null stream parameter.

The documentation needs to be corrected to reflect this.