Compartir a través de


MediaElement.SetSource Method (Stream)

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

Sets the Source property using the supplied stream.

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

Syntax

'Declaration
Public Sub SetSource ( _
    stream As Stream _
)
public void SetSource(
    Stream stream
)

Parameters

  • stream
    Type: System.IO.Stream
    A stream that contains a natively supported media source.

Exceptions

Exception Condition
ArgumentNullException

The stream is null.

Remarks

Use this method rather than setting the Source to a URI for cases where you already have the media available as a stream. For instance, you might have preloaded media by calls to WebClient APIs and have them available as streams already. For details on this technique, see Downloading Content on Demand.

Platform Notes

Silverlight for Windows Phone Silverlight for Windows Phone

 Passing a generic stream to SetSource(System.IO.Stream) is not supported in Silverlight for Windows Phone. However, the IsolatedStorageFileStream class, which derives from Stream, is suppoted on Silverlight for Windows Phone.

For additional information on using this method, see Media in Silverlight for Windows Phone.

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.