Source Property

MediaElement.Source Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets a media source on the MediaElement.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

Public Property Source As Uri
<MediaElement Source="uri" .../>

Property Value

Type: System.Uri
A string that specifies the source of the element, as a Uniform Resource Identifier (URI). The default value is Nothing.

Dependency property identifier field: SourceProperty

Setting the Source will reset the media's Position to 00:00:00.

The string provided for the Source property is interpreted as a Uniform Resource Identifier (URI). This is in contrast to an Internationalized Resource Identifier (IRI). This distinction means that characters used to identify a Source that are outside of US-ASCII will need to be encoded.

Relative references are permitted.

Cross-domain URIs are permitted (using http). You can also use the monikers mms:, rtsp:, or rtspt: in your URI to point to a media source. In each case the actual protocol and URI scheme falls back to http (with possible further fallbacks in behavior for differentiating streaming from progressive downloads), but the value of Source will retain your moniker regardless of the runtime resolution of the URI.

By using the SetSource method instead of setting Source directly, you can download content as a package and access parts from within the package.

You can specify an initial Source value of "" (empty string) in your XAML MediaElement object element, and then set the value in code at a later time. This creates a non-playing placeholder MediaElement that you could later set a specific Source for in response to a user choice.

The MediaFailed event can occur if the initial Source attribute value in XAML does not specify a valid source.

Setting a cross-domain URI for Source will either succeed or will not return a valid status for any failure. In this case, a MediaFailed event does not occur.

Backslashes (\) in Source URIs are not permitted; always use forward slashes (/).


If you use this API in your app, you must specify the following capabilities in the app manifest. Otherwise, your app might not work correctly or it might exit unexpectedly.


Windows Phone 8, Windows Phone OS 7.1

For more info, see App capabilities and hardware requirements for Windows Phone 8.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2018 Microsoft