MediaElement MediaElement MediaElement MediaElement Class

Definition

Represents an object that renders audio and video to the display. See Remarks.

public : sealed class MediaElement : FrameworkElement, IMediaElement, IMediaElement2, IMediaElement3
struct winrt::Windows::UI::Xaml::Controls::MediaElement : FrameworkElement, IMediaElement, IMediaElement2, IMediaElement3
public sealed class MediaElement : FrameworkElement, IMediaElement, IMediaElement2, IMediaElement3
Public NotInheritable Class MediaElement Inherits FrameworkElement Implements IMediaElement, IMediaElement2, IMediaElement3
<MediaElement .../>
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

This code creates a MediaElement with the AutoPlay property explicitly set to true and the Source set to the path of a video file that is included in the app.

<MediaElement Source="Media/video1.mp4" AutoPlay="True" />
<MediaElement x:Name="mediaPlayer" 
              Source="Videos/video1.mp4" 
              Width="400" 
              AutoPlay="False"
              AreTransportControlsEnabled="True" />
<Grid>
    <Button Content="Show Popup" Click="ShowPopupClicked"/>
    <Popup x:Name="mediaPlayerPopup">
        <StackPanel Height="1400" Width="1400" Background="Blue">
            <MediaElement x:Name="mediaPlayer" 
                  AreTransportControlsEnabled="True" 
                  Source="Media/Intro.wmv"/>
            <TextBlock Text="Simple Popup"/>
            <Button Content="Close" Click="ClosePopupClicked"/>
        </StackPanel>
    </Popup>
</Grid>

long token;

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    token = mediaPlayer.RegisterPropertyChangedCallback(MediaElement.IsFullWindowProperty, OnMEFullWindowChanged);
    base.OnNavigatedTo(e);
}

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
    mediaPlayer.UnregisterPropertyChangedCallback(MediaElement.IsFullWindowProperty, token);
}

private void OnMEFullWindowChanged(DependencyObject sender, DependencyProperty dp)
{
    MediaElement me = (MediaElement)sender;

    if (me != null && dp == MediaElement.IsFullWindowProperty)
    {
        if (me.IsFullWindow == true)
        {
            mediaPlayerPopup.Visibility = Visibility.Collapsed;
        }
        else
        {
            mediaPlayerPopup.Visibility = Visibility.Visible;
        }
    }  
}

private void ClosePopupClicked(object sender, RoutedEventArgs e)
{
    // If the Popup is open, then close it.
    if (mediaPlayerPopup.IsOpen) { mediaPlayerPopup.IsOpen = false; }
}

// Handles the Click event on the Button on the page and opens the Popup. 
private void ShowPopupClicked(object sender, RoutedEventArgs e)
{
    // Open the Popup if it isn't open already. 
    if (!mediaPlayerPopup.IsOpen) { mediaPlayerPopup.IsOpen = true; }
}

Remarks

Important

In Windows 10, build 1607 and on we recommend that you use MediaPlayerElement in place of MediaElement. MediaPlayerElement has the same functionality as MediaElement, while also enabling more advanced media playback scenarios. Additionally, all future improvements in media playback will happen in MediaPlayerElement.

Use a MediaElement control to play audio and video files in your app. Built– in media transport controls let users interact with their media by providing a default playback experience comprised of various buttons including play, pause, closed captions, and others. See MediaTransportControls for more info.

For info about the media formats that MediaElement supports, see Supported codecs.

For info about performance related to MediaElement, see Optimize animations and media.

Set the media source

Set the Source property of the MediaElement object to point to an audio or video file. The property can be set to the Uniform Resource Identifier (URI) of a file that is included with the app or the Uniform Resource Identifier (URI) of a file on the network. You can use the SetSource method to set the source to a file retrieved from the local system by using a FileOpenPicker object.

By default, the media that is defined by the Source property plays immediately after the MediaElement object has loaded. To suppress the media from starting automatically, set the AutoPlay property to false.

Live media streams report a NaturalDuration of Int64.MaxValue.

Here's how to create a MediaElement in XAML with the Source set to the path of a video file that is included in the app and the AutoPlay property explicitly set to false.

<MediaElement Source="Media/video1.mp4" AutoPlay="false"/>

Here's how to create the MediaElement in code.

MediaElement mediaElement1 = new MediaElement();
mediaElement1.Source = new Uri("ms-appx:///Media/video1.mp4");
mediaElement1.AutoPlay = false;

// Add the MediaElement to the page.
rootGrid.Children.Add(mediaElement1);

Handle media events

You can respond to common media events such as the MediaOpened, MediaEnded, MediaFailed, and CurrentStateChanged events. It is good practice to always handle the MediaFailed event.

Transport controls

Set the AreTransportControlsEnabled property to programmatically enable and disable the built in transport controls for the MediaElement. The built in transport controls provide UI for playing, stopping, pausing, and seeking the media, as well as UI for volume, mute, full window, track selection, and remaining time.

You can create your own media transport controls by setting AreTransportControlsEnabled to false, and using the Play, Pause, and Stop methods. MediaElement also exposes a rich set of properties you can control like Position, Volume, IsMuted, IsLooping, PlaybackRate, and Balance.

Tip

For better performance, avoid data binding to the Position property to reflect frequent position updates (for example with a progress bar). Instead, use the DispatcherTimer to query the Position property.

For more info and examples, see Create custom transport controls.

Open local media files

To open files on the local system or from Microsoft OneDrive, you can use the FileOpenPicker to get the file and SetSource to set the media source, or you can programmatically access the user media folders.

If your app needs access without user interaction to the Music or Video folders, for example if you are enumerating all the music or video files in the user's collection and displaying them in your app, then you need to declare the Music Library and Video Library capabilities. For more info, see Files and folders in the Music, Pictures, and Videos libraries.

The FileOpenPicker does not require special Capabilities to access files on the local file system, such as the user's Music or Video folders, since the user has complete control over which file is being accessed. From a security and privacy standpoint, it is best to minimize the number of capabilities your app uses.

To open local media using FileOpenPicker

    1. Call FileOpenPicker to let the user pick a media file.

Use the FileOpenPicker class to select a media file. Set the FileTypeFilter to specify which file types the FileOpenPicker will display. Call PickSingleFileAsync to launch the file picker and get the file.

  1. Call SetSource to set the chosen media file as the MediaElement.Source.

To set the Source of the MediaElement to the StorageFile returned from the FileOpenPicker, you need to open a stream. Call the OpenAsync method on the StorageFile returns a stream that you can pass into the MediaElement.SetSource method. Then call Play on the MediaElement to start the media. This example shows how to use the FileOpenPicker to choose a file and set the file as the Source of a MediaElement.

<MediaElement x:Name="mediaPlayer"/>
...
<Button Content="Choose file" Click="Button_Click"/>
private async void Button_Click(object sender, RoutedEventArgs e)
{
    await SetLocalMedia();
}

async private System.Threading.Tasks.Task SetLocalMedia()
{
    var openPicker = new Windows.Storage.Pickers.FileOpenPicker();

    openPicker.FileTypeFilter.Add(".wmv");
    openPicker.FileTypeFilter.Add(".mp4");
    openPicker.FileTypeFilter.Add(".wma");
    openPicker.FileTypeFilter.Add(".mp3");

    var file = await openPicker.PickSingleFileAsync();

    // mediaPlayer is a MediaElement defined in XAML
    if (file != null)
    {
        var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
        mediaPlayer.SetSource(stream, file.ContentType);

        mediaPlayer.Play();
    }
}

Select audio tracks in different languages

Use the AudioStreamIndex property and the GetAudioStreamLanguage method to change the audio to a different language track on a video. Videos can also contain multiple audio tracks in the same language, such as director commentaries on films. This example specifically shows how to switch between different languages, but you can modify this code to switch between any audio tracks.

To select audio tracks in different languages

  1. Get the audio tracks.

To search for a track in a specific language, start by iterating through each audio track on the video. Use AudioStreamCount as the max value for a for loop.

  1. Get the language of the audio track.

Use the GetAudioStreamLanguage method to get the language of the track. The language of the track is identified by a language code, such as "en" for English or "ja" for Japanese.

  1. Set the active audio track.

When you find the track with the desired language, set the AudioStreamIndex to the index of the track. Setting AudioStreamIndex to null selects the default audio track which is defined by the content. Here's some code that attempts to set the audio track to the specified language. It iterates through the audio tracks on a MediaElement object and uses GetAudioStreamLanguage to get the language of each track. If the desired language track exists, the AudioStreamIndex is set to the index of that track.

/// <summary>
/// Attemps to set the audio track of a video to a specific language
/// </summary>
/// <param name="lcid">The id of the language. For example, "en" or "ja"</param>
/// <returns>true if the track was set; otherwise, false.</returns>
private bool SetAudioLanguage(string lcid, MediaElement media)
{
    bool wasLanguageSet = false;

    for (int index = 0; index < media.AudioStreamCount; index++)
    {
        if (media.GetAudioStreamLanguage(index) == lcid)
        {
            media.AudioStreamIndex = index;
            wasLanguageSet = true;
        }
    }

    return wasLanguageSet;
}

Full window playback

Use the IsFullWindow property to enable and disable full window rendering. When in full-window mode, input events received on the MediaElement will still route through to the visual tree in the background. For example, if the MediaElement is in a ListBox, turning the scroll wheel could cause the ListBox to scroll in the background. This can cause unexpected behavior. If input events should not be routed when in full-window mode, the MediaElement should handle the events.

Note

We recommend that you not use MediaElement in a Popup control. If a MediaElement hosted in a Popup is switched to full-window mode, the Popup is rendered on top of the MediaElement. If you must use a MediaElement in a Popup, you should collapse the Popup when the MediaElement enters full-window mode, and restore the Popup when the MediaElement exits full-window mode. Use DependencyProperty.RegisterPropertyChangedCallback to be notified when the MediaElement.IsFullWindow property changes. For an example, see the Examples section.

Keep media playing

To prevent the display from being deactivated when user action is no longer detected, such as when an app is playing video, you can call DisplayRequest.RequestActive. To conserve power and battery life, you should call DisplayRequest.RequestRelease to release the display request as soon as it is no longer required.

Here are some situations when you should release the display request:

  • Video playback is paused, for example by user action, buffering, or adjustment due to limited bandwidth.
  • Playback stops. For example, the video is done playing or the presentation is over.
  • A playback error has occurred. For example, network connectivity issues or a corrupted file. Here, you use the CurrentStateChanged event to detect these situations. Then, use the IsAudioOnly property to determine whether an audio or video file is playing, and keep the screen active only if video is playing.
<MediaElement Source="Media/video1.mp4"
              CurrentStateChanged="MediaElement_CurrentStateChanged"/>

// Create this variable at a global scope. Set it to null.
private DisplayRequest appDisplayRequest = null;

private void MediaElement_CurrentStateChanged(object sender, RoutedEventArgs e)
{
    MediaElement mediaElement = sender as MediaElement;
    if (mediaElement != null && mediaElement.IsAudioOnly == false)
    {
        if (mediaElement.CurrentState == Windows.UI.Xaml.Media.MediaElementState.Playing)
        {                
            if (appDisplayRequest == null)
            {
                // This call creates an instance of the DisplayRequest object. 
                appDisplayRequest = new DisplayRequest();
                appDisplayRequest.RequestActive();
            }
        }
        else // CurrentState is Buffering, Closed, Opening, Paused, or Stopped. 
        {
            if (appDisplayRequest != null)
            {
                // Deactivate the display request and set the var to null.
                appDisplayRequest.RequestRelease();
                appDisplayRequest = null;
            }
        }            
    }
}

Poster source

You can use the PosterSource property to provide your MediaElement with a visual representation before the media is loaded. A PosterSource is an image, such as a screen shot or movie poster, that is displayed in place of the media. The PosterSource is displayed in the following situations:

  • When a valid source is not set. For example, Source is not set, Source was set to Null, or the source is invalid (as is the case when a MediaFailed event fires).
  • While media is loading. For example, a valid source is set, but the MediaOpened event has not fired yet.
  • When media is streaming to another device.
  • When the media is audio only.

Notes for previous versions

Windows 8.1

On Windows Phone, you can only have one MediaElement at a time.

To let audio continue to play when your app is in the background, set the AudioCategory property to BackgroundCapableMedia. This also requires declaring the "Audio" background task capability in the app manifest. These values are deprecated in Windows 10.

Windows 8

Prior to Windows 8.1, the IsFullWindow property in not available. To enable full window video playback you must set the Width and Height of the MediaElement to the Window.Bounds of the current window. Specifically, use Window.Current.Bounds.Width and Window.Current.Bounds.Height. Full window playback will not take advantage of system optimizations if you set the dimensions of a parent element, such as a grid, or a containing element instead of the MediaElement.

Prior to Windows 8.1, the Opacity property is not supported on MediaElement.

Prior to Windows 8.1, the AreTransportControlsEnabled property and built-in transport controls are not available. You must provide your own transport controls. For more info and examples, see Create custom transport controls and scenario 4 of the XAML media playback sample.

Windows Phone 8

Windows Phone 8.x app must use PickSingleFileAndContinue to open local media files.

Constructors

MediaElement() MediaElement() MediaElement() MediaElement()

Instantiates a new instance of the MediaElement class.

public : MediaElement()
MediaElement() const;
public MediaElement()
Public Sub New()

Properties

AccessKey AccessKey AccessKey AccessKey

Gets or sets the access key (mnemonic) for this element.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AccessKeyProperty AccessKeyProperty AccessKeyProperty AccessKeyProperty

Identifies for the AccessKey dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AccessKeyScopeOwner AccessKeyScopeOwner AccessKeyScopeOwner AccessKeyScopeOwner

Gets or sets a source element that provides the access key scope for this element, even if it's not in the visual tree of the source element.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AccessKeyScopeOwnerProperty AccessKeyScopeOwnerProperty AccessKeyScopeOwnerProperty AccessKeyScopeOwnerProperty

Identifies for the AccessKeyScopeOwner dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

ActualHeight ActualHeight ActualHeight ActualHeight

Gets the rendered height of a FrameworkElement. See Remarks.

(Inherited from FrameworkElement)

ActualHeightProperty ActualHeightProperty ActualHeightProperty ActualHeightProperty

Identifies the ActualHeight dependency property. See Remarks.

(Inherited from FrameworkElement)

ActualStereo3DVideoPackingMode ActualStereo3DVideoPackingMode ActualStereo3DVideoPackingMode ActualStereo3DVideoPackingMode

Gets an enumeration value that determines the current value of stereo 3-D video frame-packing mode, accounting for other factors such as whether the media engine is ready for use.

public : Stereo3DVideoPackingMode ActualStereo3DVideoPackingMode { get; }
Stereo3DVideoPackingMode ActualStereo3DVideoPackingMode();
public Stereo3DVideoPackingMode ActualStereo3DVideoPackingMode { get; }
Public ReadOnly Property ActualStereo3DVideoPackingMode As Stereo3DVideoPackingMode
Value
Stereo3DVideoPackingMode Stereo3DVideoPackingMode

A value of the enumeration. May be None if media engine is not ready for use.

Remarks

ActualStereo3DVideoPackingMode is used to determine the current Stereo3DVideoPackingMode being used by the subsystem. This could be different than what is set by the app author or if the app author sets None which is the default of Stereo3DVideoPackingMode.

See Also

ActualStereo3DVideoPackingModeProperty ActualStereo3DVideoPackingModeProperty ActualStereo3DVideoPackingModeProperty ActualStereo3DVideoPackingModeProperty

Identifies the ActualStereo3DVideoPackingMode dependency property.

public : static DependencyProperty ActualStereo3DVideoPackingModeProperty { get; }
static DependencyProperty ActualStereo3DVideoPackingModeProperty();
public static DependencyProperty ActualStereo3DVideoPackingModeProperty { get; }
Public Static ReadOnly Property ActualStereo3DVideoPackingModeProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the ActualStereo3DVideoPackingMode dependency property.

ActualTheme ActualTheme ActualTheme ActualTheme

Gets the UI theme that is currently used by the element, which might be different than the RequestedTheme.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

ActualThemeProperty ActualThemeProperty ActualThemeProperty ActualThemeProperty

Identifies the ActualTheme dependency property.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

ActualWidth ActualWidth ActualWidth ActualWidth

Gets the rendered width of a FrameworkElement. See Remarks.

(Inherited from FrameworkElement)

ActualWidthProperty ActualWidthProperty ActualWidthProperty ActualWidthProperty

Identifies the ActualWidth dependency property. See Remarks.

(Inherited from FrameworkElement)

AllowDrop AllowDrop AllowDrop AllowDrop

Gets or sets a value that determines whether this UIElement can be a drop target for purposes of drag-and-drop operations.

(Inherited from UIElement)

AllowDropProperty AllowDropProperty AllowDropProperty AllowDropProperty

Identifies the AllowDrop dependency property.

(Inherited from UIElement)

AllowFocusOnInteraction AllowFocusOnInteraction AllowFocusOnInteraction AllowFocusOnInteraction

Gets or sets a value that indicates whether the element automatically gets focus when the user interacts with it.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AllowFocusOnInteractionProperty AllowFocusOnInteractionProperty AllowFocusOnInteractionProperty AllowFocusOnInteractionProperty

Identifies for the AllowFocusOnInteraction dependency property.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AllowFocusWhenDisabled AllowFocusWhenDisabled AllowFocusWhenDisabled AllowFocusWhenDisabled

Gets or sets whether a disabled control can receive focus.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AllowFocusWhenDisabledProperty AllowFocusWhenDisabledProperty AllowFocusWhenDisabledProperty AllowFocusWhenDisabledProperty

Identifies the AllowFocusWhenDisabled dependency property.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AreTransportControlsEnabled AreTransportControlsEnabled AreTransportControlsEnabled AreTransportControlsEnabled

Gets or sets a value that determines whether the standard transport controls are enabled.

public : Platform::Boolean AreTransportControlsEnabled { get; set; }
bool AreTransportControlsEnabled(); void AreTransportControlsEnabled(bool aretransportcontrolsenabled);
public bool AreTransportControlsEnabled { get; set; }
Public ReadWrite Property AreTransportControlsEnabled As bool
<MediaElement AreTransportControlsEnabled="bool" />
Value
bool bool

true if the standard transport controls are enabled; otherwise, false. The default is false.

Examples

Here is some code that creates a MediaElement with the built-in transport controls enabled and the AutoPlay property set to false.

<MediaElement x:Name="mediaPlayer" 
              Source="Videos/video1.mp4" 
              Width="400" 
              AutoPlay="False"
              AreTransportControlsEnabled="True" />

Remarks

The transport controls are exposed as a MediaTransportControls object that you can access through the MediaElement.TransportControls property. See MediaTransportControls for more info.

If AreTransportControlsEnabled is true, the standard transport controls are enabled and displayed on the MediaElement. If AreTransportControlsEnabled is false, the standard transport controls are not enabled and are not displayed.

The transport controls hide themselves after a short period of no user interaction with the MediaElement. They reappear when the user interacts with the MediaElement.

If the Width of MediaElement is not sufficient to display all of the transport controls, a subset of the controls are displayed.

Notes for previous versions

Windows 8.1 You can't access and modify the built-in transport controls. If you create custom transport controls for your app, set this property to false to disable the built-in controls.

AreTransportControlsEnabledProperty AreTransportControlsEnabledProperty AreTransportControlsEnabledProperty AreTransportControlsEnabledProperty

Identifies the AreTransportControlsEnabled dependency property.

public : static DependencyProperty AreTransportControlsEnabledProperty { get; }
static DependencyProperty AreTransportControlsEnabledProperty();
public static DependencyProperty AreTransportControlsEnabledProperty { get; }
Public Static ReadOnly Property AreTransportControlsEnabledProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the AreTransportControlsEnabled dependency property.

AspectRatioHeight AspectRatioHeight AspectRatioHeight AspectRatioHeight

Gets the height portion of the native aspect ratio of the media.

public : int AspectRatioHeight { get; }
int32_t AspectRatioHeight();
public int AspectRatioHeight { get; }
Public ReadOnly Property AspectRatioHeight As int
Value
int int

The height portion of the native aspect ratio of the media. This value holds meaning only when you compare it with the value for the AspectRatioWidth property; the two properties together describe the aspect ratio.

AspectRatioHeightProperty AspectRatioHeightProperty AspectRatioHeightProperty AspectRatioHeightProperty

Identifies the AspectRatioHeight dependency property.

public : static DependencyProperty AspectRatioHeightProperty { get; }
static DependencyProperty AspectRatioHeightProperty();
public static DependencyProperty AspectRatioHeightProperty { get; }
Public Static ReadOnly Property AspectRatioHeightProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the AspectRatioHeight dependency property.

AspectRatioWidth AspectRatioWidth AspectRatioWidth AspectRatioWidth

Gets the width portion of the native aspect ratio of the media.

public : int AspectRatioWidth { get; }
int32_t AspectRatioWidth();
public int AspectRatioWidth { get; }
Public ReadOnly Property AspectRatioWidth As int
Value
int int

The width portion of the native aspect ratio of the media. This value holds meaning only when you compare it with the value for the AspectRatioHeight property; the two properties together describe the aspect ratio.

AspectRatioWidthProperty AspectRatioWidthProperty AspectRatioWidthProperty AspectRatioWidthProperty

Identifies the AspectRatioWidth dependency property.

public : static DependencyProperty AspectRatioWidthProperty { get; }
static DependencyProperty AspectRatioWidthProperty();
public static DependencyProperty AspectRatioWidthProperty { get; }
Public Static ReadOnly Property AspectRatioWidthProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the AspectRatioWidth dependency property.

AudioCategory AudioCategory AudioCategory AudioCategory

Gets or sets a value that describes the purpose of the audio information in an audio stream.

public : AudioCategory AudioCategory { get; set; }
AudioCategory AudioCategory(); void AudioCategory(AudioCategory audiocategory);
public AudioCategory AudioCategory { get; set; }
Public ReadWrite Property AudioCategory As AudioCategory
<MediaElement AudioCategory="audioCategoryMemberName" /.
Value
AudioCategory AudioCategory

A value of the enumeration.

Remarks

For hardware audio offload to be automatically applied, the audio category must be set to ForegroundOnlyMedia or BackgroundCapableMedia. Hardware audio offload optimizes audio rendering which can improve functionality and battery life.

AudioCategoryProperty AudioCategoryProperty AudioCategoryProperty AudioCategoryProperty

Identifies the AudioCategory dependency property.

public : static DependencyProperty AudioCategoryProperty { get; }
static DependencyProperty AudioCategoryProperty();
public static DependencyProperty AudioCategoryProperty { get; }
Public Static ReadOnly Property AudioCategoryProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the AudioCategory dependency property.

AudioDeviceType AudioDeviceType AudioDeviceType AudioDeviceType

Gets or sets a value that describes the primary usage of the device that is being used to play back audio.

public : AudioDeviceType AudioDeviceType { get; set; }
AudioDeviceType AudioDeviceType(); void AudioDeviceType(AudioDeviceType audiodevicetype);
public AudioDeviceType AudioDeviceType { get; set; }
Public ReadWrite Property AudioDeviceType As AudioDeviceType
<MediaElement AudioDeviceType="audioDeviceTypeMemberName" /.
Value
AudioDeviceType AudioDeviceType

A value of the enumeration.

AudioDeviceTypeProperty AudioDeviceTypeProperty AudioDeviceTypeProperty AudioDeviceTypeProperty

Identifies the AudioDeviceType dependency property.

public : static DependencyProperty AudioDeviceTypeProperty { get; }
static DependencyProperty AudioDeviceTypeProperty();
public static DependencyProperty AudioDeviceTypeProperty { get; }
Public Static ReadOnly Property AudioDeviceTypeProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the AudioDeviceType dependency property.

AudioStreamCount AudioStreamCount AudioStreamCount AudioStreamCount

Gets the number of audio streams that exist in the current media file.

public : int AudioStreamCount { get; }
int32_t AudioStreamCount();
public int AudioStreamCount { get; }
Public ReadOnly Property AudioStreamCount As int
Value
int int

The number of audio streams that exist in the source media file. The default value is 0.

AudioStreamCountProperty AudioStreamCountProperty AudioStreamCountProperty AudioStreamCountProperty

Identifies the AudioStreamCount dependency property.

public : static DependencyProperty AudioStreamCountProperty { get; }
static DependencyProperty AudioStreamCountProperty();
public static DependencyProperty AudioStreamCountProperty { get; }
Public Static ReadOnly Property AudioStreamCountProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the AudioStreamCount dependency property.

AudioStreamIndex AudioStreamIndex AudioStreamIndex AudioStreamIndex

Gets or sets the index of the audio stream that plays along with the video component. The collection of audio streams is composed at run time and represents all audio streams that are available in the media file.

public : IReference<int> AudioStreamIndex { get; set; }
IReference<int32_t> AudioStreamIndex(); void AudioStreamIndex(IReference<int32_t> audiostreamindex);
public Nullable<int> AudioStreamIndex { get; set; }
Public ReadWrite Property AudioStreamIndex As Nullable<int>
<MediaElement AudioStreamIndex="int"/>
Value
Nullable<int> Nullable<int>

The index in the media file of the audio component that plays along with the video component. The index can be unspecified, in which case the value is null. The default value is null.

If you're programming using C#or Microsoft Visual Basic, the type of this property is projected as int?(a nullable integer).

Remarks

Setting AudioStreamIndex to null selects the default audio track, which is defined by the content.

AudioStreamIndexProperty AudioStreamIndexProperty AudioStreamIndexProperty AudioStreamIndexProperty

Identifies the AudioStreamIndex dependency property.

public : static DependencyProperty AudioStreamIndexProperty { get; }
static DependencyProperty AudioStreamIndexProperty();
public static DependencyProperty AudioStreamIndexProperty { get; }
Public Static ReadOnly Property AudioStreamIndexProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the AudioStreamIndex dependency property.

AutoPlay AutoPlay AutoPlay AutoPlay

Gets or sets a value that indicates whether media will begin playback automatically when the Source property is set.

public : Platform::Boolean AutoPlay { get; set; }
bool AutoPlay(); void AutoPlay(bool autoplay);
public bool AutoPlay { get; set; }
Public ReadWrite Property AutoPlay As bool
<MediaElement AutoPlay="bool" .../>
Value
bool bool

true if playback is automatic; otherwise, false. The default is true.

AutoPlayProperty AutoPlayProperty AutoPlayProperty AutoPlayProperty

Identifies the AutoPlay dependency property.

public : static DependencyProperty AutoPlayProperty { get; }
static DependencyProperty AutoPlayProperty();
public static DependencyProperty AutoPlayProperty { get; }
Public Static ReadOnly Property AutoPlayProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the AutoPlay dependency property.

Balance Balance Balance Balance

Gets or sets a ratio of volume across stereo speakers.

public : double Balance { get; set; }
double Balance(); void Balance(double balance);
public double Balance { get; set; }
Public ReadWrite Property Balance As double
<MediaElement Balance="double"  .../>
Value
double double

The ratio of volume across speakers in the range between -1 and 1. The default value is 0.

BalanceProperty BalanceProperty BalanceProperty BalanceProperty

Identifies the Balance dependency property.

public : static DependencyProperty BalanceProperty { get; }
static DependencyProperty BalanceProperty();
public static DependencyProperty BalanceProperty { get; }
Public Static ReadOnly Property BalanceProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the Balance dependency property.

BaseUri BaseUri BaseUri BaseUri

Gets a Uniform Resource Identifier (URI) that represents the base Uniform Resource Identifier (URI) for an XAML-constructed object at XAML load time. This property is useful for Uniform Resource Identifier (URI) resolution at run time.

(Inherited from FrameworkElement)

BringIntoViewRequestedEvent BringIntoViewRequestedEvent BringIntoViewRequestedEvent BringIntoViewRequestedEvent

Prerelease. Gets the identifier for the BringIntoViewRequested routed event.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

BufferingProgress BufferingProgress BufferingProgress BufferingProgress

Gets a value that indicates the current buffering progress.

public : double BufferingProgress { get; }
double BufferingProgress();
public double BufferingProgress { get; }
Public ReadOnly Property BufferingProgress As double
Value
double double

The amount of buffering that is completed for media content. The value ranges from 0 to 1. Multiply by 100 to obtain a percentage.

BufferingProgressProperty BufferingProgressProperty BufferingProgressProperty BufferingProgressProperty

Identifies the BufferingProgress dependency property.

public : static DependencyProperty BufferingProgressProperty { get; }
static DependencyProperty BufferingProgressProperty();
public static DependencyProperty BufferingProgressProperty { get; }
Public Static ReadOnly Property BufferingProgressProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the BufferingProgress dependency property.

CacheMode CacheMode CacheMode CacheMode

Gets or sets a value that indicates that rendered content should be cached as a composited bitmap when possible.

(Inherited from UIElement)

CacheModeProperty CacheModeProperty CacheModeProperty CacheModeProperty

Identifies the CacheMode dependency property.

(Inherited from UIElement)

CanDrag CanDrag CanDrag CanDrag

Gets or sets a value that indicates whether the element can be dragged as data in a drag-and-drop operation.

(Inherited from UIElement)

CanDragProperty CanDragProperty CanDragProperty CanDragProperty

Identifies the CanDrag dependency property.

(Inherited from UIElement)

CanPause CanPause CanPause CanPause

Gets a value that indicates whether media can be paused if the Pause method is called.

public : Platform::Boolean CanPause { get; }
bool CanPause();
public bool CanPause { get; }
Public ReadOnly Property CanPause As bool
Value
bool bool

true if the media can be paused; otherwise, false.

CanPauseProperty CanPauseProperty CanPauseProperty CanPauseProperty

Identifies the CanPause dependency property.

public : static DependencyProperty CanPauseProperty { get; }
static DependencyProperty CanPauseProperty();
public static DependencyProperty CanPauseProperty { get; }
Public Static ReadOnly Property CanPauseProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the CanPause dependency property.

CanSeek CanSeek CanSeek CanSeek

Gets a value that indicates whether media can be repositioned by setting the value of the Position property.

public : Platform::Boolean CanSeek { get; }
bool CanSeek();
public bool CanSeek { get; }
Public ReadOnly Property CanSeek As bool
Value
bool bool

true if the media can be repositioned; otherwise, false.

CanSeekProperty CanSeekProperty CanSeekProperty CanSeekProperty

Identifies the CanSeek dependency property.

public : static DependencyProperty CanSeekProperty { get; }
static DependencyProperty CanSeekProperty();
public static DependencyProperty CanSeekProperty { get; }
Public Static ReadOnly Property CanSeekProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the CanSeek dependency property.

CharacterReceivedEvent CharacterReceivedEvent CharacterReceivedEvent CharacterReceivedEvent

Gets the identifier for the CharacterReceived routed event.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Clip Clip Clip Clip

Gets or sets the RectangleGeometry used to define the outline of the contents of a UIElement.

(Inherited from UIElement)

ClipProperty ClipProperty ClipProperty ClipProperty

Identifies the Clip dependency property.

(Inherited from UIElement)

CompositeMode CompositeMode CompositeMode CompositeMode

Gets or sets a property that declares alternate composition and blending modes for the element in its parent layout and window. This is relevant for elements that are involved in a mixed XAML / Microsoft DirectX UI.

(Inherited from UIElement)

CompositeModeProperty CompositeModeProperty CompositeModeProperty CompositeModeProperty

Identifies the CompositeMode dependency property.

(Inherited from UIElement)

ContextFlyout ContextFlyout ContextFlyout ContextFlyout

Gets or sets the flyout associated with this element.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

ContextFlyoutProperty ContextFlyoutProperty ContextFlyoutProperty ContextFlyoutProperty

Identifies for the ContextFlyout dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

ContextRequestedEvent ContextRequestedEvent ContextRequestedEvent ContextRequestedEvent

Prerelease. Gets the identifier for the ContextRequested routed event.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

CurrentState CurrentState CurrentState CurrentState

Gets the status of this MediaElement.

public : MediaElementState CurrentState { get; }
MediaElementState CurrentState();
public MediaElementState CurrentState { get; }
Public ReadOnly Property CurrentState As MediaElementState
Value
MediaElementState MediaElementState

The current state of this MediaElement. The state can be one of the following (as defined in the MediaElementState enumeration): Buffering, Closed, Opening, Paused, Playing, or Stopped. The default value is Closed.

Examples

The following example demonstrates one way to display the CurrentState of a MediaElement. It creates a MediaElement and several buttons for controlling media playback. To display the current state of the MediaElement, the example registers for the CurrentStateChanged event and uses an event handler to update a TextBlock.

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <MediaElement CurrentStateChanged="Media_State_Changed"
        x:Name="media" Source="xbox.wmv" Width="300" Height="300" 
                  Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" />

    <!-- Stops media playback.-->
    <Button Click="StopMedia" 
     Grid.Column="0" Grid.Row="1" Content="Stop" />

    <!-- Pauses media playback. -->
    <Button Click="PauseMedia" 
     Grid.Column="1" Grid.Row="1" Content="Pause" />

    <!-- Begins media playback. -->
    <Button Click="PlayMedia" 
     Grid.Column="2" Grid.Row="1" Content="Play" />

    <TextBlock
Grid.Column="0" Grid.Row="2" Margin="10" 
FontSize="12">CurrentState:</TextBlock>

    <TextBlock 
x:Name="mediaStateTextBlock"
Grid.Column="1" Grid.Row="2" Margin="0,10,0,0"
FontSize="12"></TextBlock>

</Grid>
private void StopMedia(object sender, RoutedEventArgs e)
{
    media.Stop();
}
private void PauseMedia(object sender, RoutedEventArgs e)
{
    media.Pause();
}
private void PlayMedia(object sender, RoutedEventArgs e)
{
    media.Play();
}
private void Media_State_Changed(object sender, RoutedEventArgs e)
{
    mediaStateTextBlock.Text = media.CurrentState.ToString();
}
Private Sub StopMedia(ByVal sender As Object, ByVal e As RoutedEventArgs)
    media.Stop()
End Sub

Private Sub PauseMedia(ByVal sender As Object, ByVal e As RoutedEventArgs)
    media.Pause()
End Sub

Private Sub PlayMedia(ByVal sender As Object, ByVal e As RoutedEventArgs)
    media.Play()
End Sub
Private Sub Media_State_Changed(ByVal sender As Object, ByVal e As EventArgs)
    mediaStateTextBlock.Text = media.CurrentState.ToString
End Sub

CurrentStateProperty CurrentStateProperty CurrentStateProperty CurrentStateProperty

Identifies the CurrentState dependency property.

public : static DependencyProperty CurrentStateProperty { get; }
static DependencyProperty CurrentStateProperty();
public static DependencyProperty CurrentStateProperty { get; }
Public Static ReadOnly Property CurrentStateProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the CurrentState dependency property.

DataContext DataContext DataContext DataContext

Gets or sets the data context for a FrameworkElement when it participates in data binding.

(Inherited from FrameworkElement)

DataContextProperty DataContextProperty DataContextProperty DataContextProperty

Identifies the DataContext dependency property.

(Inherited from FrameworkElement)

DefaultPlaybackRate DefaultPlaybackRate DefaultPlaybackRate DefaultPlaybackRate

Gets or sets the default playback rate for the media engine. The playback rate applies when the user isn't using fast forward or reverse.

public : double DefaultPlaybackRate { get; set; }
double DefaultPlaybackRate(); void DefaultPlaybackRate(double defaultplaybackrate);
public double DefaultPlaybackRate { get; set; }
Public ReadWrite Property DefaultPlaybackRate As double
<MediaElement DefaultPlaybackRate="double"/>
Value
double double

The default playback rate. The default is 1.0, which indicates normal playback speed.

Remarks

The current PlaybackRate is set to the value of DefaultPlaybackRate whenever Play is called. So setting DefaultPlaybackRate to a different value has no effect until Play is called.

To set a rate that will persist throughout the lifetime of the MediaElement, use DefaultPlaybackRate. Once playback ends, due to the MediaEnded event being raised or if Pause or Stop are called, the PlaybackRate will be effectively lost.

DefaultPlaybackRateProperty DefaultPlaybackRateProperty DefaultPlaybackRateProperty DefaultPlaybackRateProperty

Identifies the DefaultPlaybackRate dependency property.

public : static DependencyProperty DefaultPlaybackRateProperty { get; }
static DependencyProperty DefaultPlaybackRateProperty();
public static DependencyProperty DefaultPlaybackRateProperty { get; }
Public Static ReadOnly Property DefaultPlaybackRateProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the DefaultPlaybackRate dependency property.

DesiredSize DesiredSize DesiredSize DesiredSize

Gets the size that this UIElement computed during the measure pass of the layout process.

(Inherited from UIElement)

Dispatcher Dispatcher Dispatcher Dispatcher

Gets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread.

(Inherited from DependencyObject)

DoubleTappedEvent DoubleTappedEvent DoubleTappedEvent DoubleTappedEvent

Gets the identifier for the DoubleTapped routed event.

(Inherited from UIElement)

DownloadProgress DownloadProgress DownloadProgress DownloadProgress

Gets a value that indicates the amount of download completed for content located on a remote server.

public : double DownloadProgress { get; }
double DownloadProgress();
public double DownloadProgress { get; }
Public ReadOnly Property DownloadProgress As double
Value
double double

A value that indicates the amount of download completed for content that is located on a remote server. The value ranges from 0 to 1. Multiply by 100 to obtain a percentage.

DownloadProgressOffset DownloadProgressOffset DownloadProgressOffset DownloadProgressOffset

Gets the offset of download progress, which is relevant in seek-ahead scenarios.

public : double DownloadProgressOffset { get; }
double DownloadProgressOffset();
public double DownloadProgressOffset { get; }
Public ReadOnly Property DownloadProgressOffset As double
Value
double double

The offset of download progress.

DownloadProgressOffsetProperty DownloadProgressOffsetProperty DownloadProgressOffsetProperty DownloadProgressOffsetProperty

Identifies the DownloadProgressOffset dependency property.

public : static DependencyProperty DownloadProgressOffsetProperty { get; }
static DependencyProperty DownloadProgressOffsetProperty();
public static DependencyProperty DownloadProgressOffsetProperty { get; }
Public Static ReadOnly Property DownloadProgressOffsetProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the DownloadProgressOffset dependency property.

DownloadProgressProperty DownloadProgressProperty DownloadProgressProperty DownloadProgressProperty

Identifies the DownloadProgress dependency property.

public : static DependencyProperty DownloadProgressProperty { get; }
static DependencyProperty DownloadProgressProperty();
public static DependencyProperty DownloadProgressProperty { get; }
Public Static ReadOnly Property DownloadProgressProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the DownloadProgress dependency property.

DragEnterEvent DragEnterEvent DragEnterEvent DragEnterEvent

Gets the identifier for the DragEnter routed event.

(Inherited from UIElement)

DragLeaveEvent DragLeaveEvent DragLeaveEvent DragLeaveEvent

Gets the identifier for the DragLeave routed event.

(Inherited from UIElement)

DragOverEvent DragOverEvent DragOverEvent DragOverEvent

Gets the identifier for the DragOver routed event.

(Inherited from UIElement)

DropEvent DropEvent DropEvent DropEvent

Gets the identifier for the Drop routed event.

(Inherited from UIElement)

ExitDisplayModeOnAccessKeyInvoked ExitDisplayModeOnAccessKeyInvoked ExitDisplayModeOnAccessKeyInvoked ExitDisplayModeOnAccessKeyInvoked

Gets or sets a value that specifies whether the access key display is dismissed when an access key is invoked.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

ExitDisplayModeOnAccessKeyInvokedProperty ExitDisplayModeOnAccessKeyInvokedProperty ExitDisplayModeOnAccessKeyInvokedProperty ExitDisplayModeOnAccessKeyInvokedProperty

Identifies the ExitDisplayModeOnAccessKeyInvoked dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

FlowDirection FlowDirection FlowDirection FlowDirection

Gets or sets the direction in which text and other UI elements flow within any parent element that controls their layout. This property can be set to either LeftToRight or RightToLeft. Setting FlowDirection to RightToLeft on any element sets the alignment to the right, the reading order to right-to-left and the layout of the control to flow from right to left.

(Inherited from FrameworkElement)

FlowDirectionProperty FlowDirectionProperty FlowDirectionProperty FlowDirectionProperty

Identifies the FlowDirection dependency property.

(Inherited from FrameworkElement)

FocusVisualMargin FocusVisualMargin FocusVisualMargin FocusVisualMargin

Gets or sets the outer margin of the focus visual for a FrameworkElement.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

FocusVisualMarginProperty FocusVisualMarginProperty FocusVisualMarginProperty FocusVisualMarginProperty

Identifies the FocusVisualMargin dependency property.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

FocusVisualPrimaryBrush FocusVisualPrimaryBrush FocusVisualPrimaryBrush FocusVisualPrimaryBrush

Gets or sets the brush used to draw the outer border of a HighVisibility focus visual for a FrameworkElement.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

FocusVisualPrimaryBrushProperty FocusVisualPrimaryBrushProperty FocusVisualPrimaryBrushProperty FocusVisualPrimaryBrushProperty

Identifies the FocusVisualPrimaryBrush dependency property.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

FocusVisualPrimaryThickness FocusVisualPrimaryThickness FocusVisualPrimaryThickness FocusVisualPrimaryThickness

Gets or sets the thickness of the outer border of a HighVisibility focus visual for a FrameworkElement.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

FocusVisualPrimaryThicknessProperty FocusVisualPrimaryThicknessProperty FocusVisualPrimaryThicknessProperty FocusVisualPrimaryThicknessProperty

Identifies the FocusVisualPrimaryThickness dependency property.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

FocusVisualSecondaryBrush FocusVisualSecondaryBrush FocusVisualSecondaryBrush FocusVisualSecondaryBrush

Gets or sets the brush used to draw the inner border of a HighVisibility focus visual for a FrameworkElement.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

FocusVisualSecondaryBrushProperty FocusVisualSecondaryBrushProperty FocusVisualSecondaryBrushProperty FocusVisualSecondaryBrushProperty

Identifies the FocusVisualSecondaryBrush dependency property.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

FocusVisualSecondaryThickness FocusVisualSecondaryThickness FocusVisualSecondaryThickness FocusVisualSecondaryThickness

Gets or sets the thickness of the inner border of a HighVisibility focus visual for a FrameworkElement.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

FocusVisualSecondaryThicknessProperty FocusVisualSecondaryThicknessProperty FocusVisualSecondaryThicknessProperty FocusVisualSecondaryThicknessProperty

Identifies the FocusVisualSecondaryThickness dependency property.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

GettingFocusEvent GettingFocusEvent GettingFocusEvent GettingFocusEvent

Gets the identifier for the GettingFocus routed event.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Height Height Height Height

Gets or sets the suggested height of a FrameworkElement.

(Inherited from FrameworkElement)

HeightProperty HeightProperty HeightProperty HeightProperty

Identifies the Height dependency property.

(Inherited from FrameworkElement)

HighContrastAdjustment HighContrastAdjustment HighContrastAdjustment HighContrastAdjustment

Gets or sets a value that indicates whether the framework automatically adjusts the element's visual properties when high contrast themes are enabled.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

HighContrastAdjustmentProperty HighContrastAdjustmentProperty HighContrastAdjustmentProperty HighContrastAdjustmentProperty

Identifies the HighContrastAdjustment dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

HoldingEvent HoldingEvent HoldingEvent HoldingEvent

Gets the identifier for the Holding routed event.

(Inherited from UIElement)

HorizontalAlignment HorizontalAlignment HorizontalAlignment HorizontalAlignment

Gets or sets the horizontal alignment characteristics that are applied to a FrameworkElement when it is composed in a layout parent, such as a panel or items control.

(Inherited from FrameworkElement)

HorizontalAlignmentProperty HorizontalAlignmentProperty HorizontalAlignmentProperty HorizontalAlignmentProperty

Identifies the HorizontalAlignment dependency property.

(Inherited from FrameworkElement)

IsAccessKeyScope IsAccessKeyScope IsAccessKeyScope IsAccessKeyScope

Gets or sets a value that indicates whether an element defines its own access key scope.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

IsAccessKeyScopeProperty IsAccessKeyScopeProperty IsAccessKeyScopeProperty IsAccessKeyScopeProperty

Identifies for the IsAccessKeyScope dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

IsAudioOnly IsAudioOnly IsAudioOnly IsAudioOnly

Gets a value that reports whether the current source media is an audio-only media file.

public : Platform::Boolean IsAudioOnly { get; }
bool IsAudioOnly();
public bool IsAudioOnly { get; }
Public ReadOnly Property IsAudioOnly As bool
Value
bool bool

true if the current source media is audio-only, otherwise, false.

IsAudioOnlyProperty IsAudioOnlyProperty IsAudioOnlyProperty IsAudioOnlyProperty

Identifies the IsAudioOnly dependency property.

public : static DependencyProperty IsAudioOnlyProperty { get; }
static DependencyProperty IsAudioOnlyProperty();
public static DependencyProperty IsAudioOnlyProperty { get; }
Public Static ReadOnly Property IsAudioOnlyProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the IsAudioOnly dependency property.

IsDoubleTapEnabled IsDoubleTapEnabled IsDoubleTapEnabled IsDoubleTapEnabled

Gets or sets a value that determines whether the DoubleTapped event can originate from that element.

(Inherited from UIElement)

IsDoubleTapEnabledProperty IsDoubleTapEnabledProperty IsDoubleTapEnabledProperty IsDoubleTapEnabledProperty

Identifies the IsDoubleTapEnabled dependency property.

(Inherited from UIElement)

IsFullWindow IsFullWindow IsFullWindow IsFullWindow

Gets a value that specifies if the MediaElement is rendering in full window mode. Setting this property enables or disables full window rendering.

public : Platform::Boolean IsFullWindow { get; set; }
bool IsFullWindow(); void IsFullWindow(bool isfullwindow);
public bool IsFullWindow { get; set; }
Public ReadWrite Property IsFullWindow As bool
<MediaElement IsFullWindow="bool" />
Value
bool bool

true if the MediaElement is in full window mode; otherwise, false. The default is false.

Remarks

Setting and un-setting this property enables and disables full window rendering.

Always use the IsFullWindow property to enable and disable full window rendering. This ensures system level optimizations are used during media playback.

When in full-window mode, input events received on the MediaElement will still route through to the visual tree in the background. For example, if the MediaElement is in a ListBox, turning the scroll wheel could cause the ListBox to scroll in the background. This can cause unexpected behavior. If input events should not be routed when in full-window mode, the MediaElement should handle the events.

IsFullWindowProperty IsFullWindowProperty IsFullWindowProperty IsFullWindowProperty

Identifies the IsFullWindow dependency property.

public : static DependencyProperty IsFullWindowProperty { get; }
static DependencyProperty IsFullWindowProperty();
public static DependencyProperty IsFullWindowProperty { get; }
Public Static ReadOnly Property IsFullWindowProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the IsFullWindow dependency property.

IsHitTestVisible IsHitTestVisible IsHitTestVisible IsHitTestVisible

Gets or sets whether the contained area of this UIElement can return true values for hit testing.

(Inherited from UIElement)

IsHitTestVisibleProperty IsHitTestVisibleProperty IsHitTestVisibleProperty IsHitTestVisibleProperty

Identifies the IsHitTestVisible dependency property.

(Inherited from UIElement)

IsHoldingEnabled IsHoldingEnabled IsHoldingEnabled IsHoldingEnabled

Gets or sets a value that determines whether the Holding event can originate from that element.

(Inherited from UIElement)

IsHoldingEnabledProperty IsHoldingEnabledProperty IsHoldingEnabledProperty IsHoldingEnabledProperty

Identifies the IsHoldingEnabled dependency property.

(Inherited from UIElement)

IsLooping IsLooping IsLooping IsLooping

Gets or sets a value that describes whether the media source currently loaded in the media engine should automatically set the position to the media start after reaching its end.

public : Platform::Boolean IsLooping { get; set; }
bool IsLooping(); void IsLooping(bool islooping);
public bool IsLooping { get; set; }
Public ReadWrite Property IsLooping As bool
<MediaElement IsLooping="bool"/>
Value
bool bool

true to loop the media and play continuously. false to not loop the media automatically. The default is false.

IsLoopingProperty IsLoopingProperty IsLoopingProperty IsLoopingProperty

Identifies the IsLooping dependency property.

public : static DependencyProperty IsLoopingProperty { get; }
static DependencyProperty IsLoopingProperty();
public static DependencyProperty IsLoopingProperty { get; }
Public Static ReadOnly Property IsLoopingProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the IsLooping dependency property.

IsMuted IsMuted IsMuted IsMuted

Gets or sets a value indicating whether the audio is muted.

public : Platform::Boolean IsMuted { get; set; }
bool IsMuted(); void IsMuted(bool ismuted);
public bool IsMuted { get; set; }
Public ReadWrite Property IsMuted As bool
<MediaElement IsMuted="bool" .../>
Value
bool bool

true if audio is muted; otherwise, false. The default is false.

IsMutedProperty IsMutedProperty IsMutedProperty IsMutedProperty

Identifies the IsMuted dependency property.

public : static DependencyProperty IsMutedProperty { get; }
static DependencyProperty IsMutedProperty();
public static DependencyProperty IsMutedProperty { get; }
Public Static ReadOnly Property IsMutedProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the IsMuted dependency property.

IsRightTapEnabled IsRightTapEnabled IsRightTapEnabled IsRightTapEnabled

Gets or sets a value that determines whether the RightTapped event can originate from that element.

(Inherited from UIElement)

IsRightTapEnabledProperty IsRightTapEnabledProperty IsRightTapEnabledProperty IsRightTapEnabledProperty

Identifies the IsRightTapEnabled dependency property.

(Inherited from UIElement)

IsStereo3DVideo IsStereo3DVideo IsStereo3DVideo IsStereo3DVideo

Gets a value that reports whether the current source media is a stereo 3-D video media file.

public : Platform::Boolean IsStereo3DVideo { get; }
bool IsStereo3DVideo();
public bool IsStereo3DVideo { get; }
Public ReadOnly Property IsStereo3DVideo As bool
Value
bool bool

true if the current source media is stereo 3-D video, otherwise, false.

Remarks

If this property value is true, check Stereo3DVideoRenderMode for information on the render mode.

IsStereo3DVideoProperty IsStereo3DVideoProperty IsStereo3DVideoProperty IsStereo3DVideoProperty

Identifies the IsStereo3DVideo dependency property.

public : static DependencyProperty IsStereo3DVideoProperty { get; }
static DependencyProperty IsStereo3DVideoProperty();
public static DependencyProperty IsStereo3DVideoProperty { get; }
Public Static ReadOnly Property IsStereo3DVideoProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the IsStereo3DVideo dependency property.

IsTapEnabled IsTapEnabled IsTapEnabled IsTapEnabled

Gets or sets a value that determines whether the Tapped event can originate from that element.

(Inherited from UIElement)

IsTapEnabledProperty IsTapEnabledProperty IsTapEnabledProperty IsTapEnabledProperty

Identifies the IsTapEnabled dependency property.

(Inherited from UIElement)

KeyDownEvent KeyDownEvent KeyDownEvent KeyDownEvent

Gets the identifier for the KeyDown routed event.

(Inherited from UIElement)

KeyTipHorizontalOffset KeyTipHorizontalOffset KeyTipHorizontalOffset KeyTipHorizontalOffset

Gets or sets a value that indicates how far left or right the Key Tip is placed in relation to the UIElement.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

KeyTipHorizontalOffsetProperty KeyTipHorizontalOffsetProperty KeyTipHorizontalOffsetProperty KeyTipHorizontalOffsetProperty

Identifies the KeyTipHorizontalOffset dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

KeyTipPlacementMode KeyTipPlacementMode KeyTipPlacementMode KeyTipPlacementMode

Gets or sets a value that indicates where the access key Key Tip is placed in relation to the boundary of the UIElement.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

KeyTipPlacementModeProperty KeyTipPlacementModeProperty KeyTipPlacementModeProperty KeyTipPlacementModeProperty

Identifies the KeyTipPlacementMode dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

KeyTipTarget KeyTipTarget KeyTipTarget KeyTipTarget

Prerelease. Gets or sets a value that indicates the element targeted by the access key Key Tip.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

KeyTipTargetProperty KeyTipTargetProperty KeyTipTargetProperty KeyTipTargetProperty

Prerelease. Identifies the KeyTipTarget dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

KeyTipVerticalOffset KeyTipVerticalOffset KeyTipVerticalOffset KeyTipVerticalOffset

Gets or sets a value that indicates how far up or down the Key Tip is placed in relation to the UI element.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

KeyTipVerticalOffsetProperty KeyTipVerticalOffsetProperty KeyTipVerticalOffsetProperty KeyTipVerticalOffsetProperty

Identifies the KeyTipVerticalOffset dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

KeyUpEvent KeyUpEvent KeyUpEvent KeyUpEvent

Gets the identifier for the KeyUp routed event.

(Inherited from UIElement)

KeyboardAcceleratorPlacementMode KeyboardAcceleratorPlacementMode KeyboardAcceleratorPlacementMode KeyboardAcceleratorPlacementMode

Prerelease. Gets or sets a value that indicates whether the control tooltip displays the key combination for it's associated keyboard accelerator.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

KeyboardAcceleratorPlacementModeProperty KeyboardAcceleratorPlacementModeProperty KeyboardAcceleratorPlacementModeProperty KeyboardAcceleratorPlacementModeProperty

Prerelease. Identifies the KeyboardAcceleratorPlacementMode dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

KeyboardAcceleratorPlacementTarget KeyboardAcceleratorPlacementTarget KeyboardAcceleratorPlacementTarget KeyboardAcceleratorPlacementTarget

Prerelease. Gets or sets a value that indicates the control tooltip that displays the accelerator key combination.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

KeyboardAcceleratorPlacementTargetProperty KeyboardAcceleratorPlacementTargetProperty KeyboardAcceleratorPlacementTargetProperty KeyboardAcceleratorPlacementTargetProperty

Prerelease. Identifies the KeyboardAcceleratorPlacementTarget dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

KeyboardAccelerators KeyboardAccelerators KeyboardAccelerators KeyboardAccelerators

Gets the the collection of key combinations that invoke an action using the keyboard.

Accelerators are typically assigned to buttons or menu items.

Example of a menu showing keyboard accelerators for various menu items
Example of a menu showing keyboard accelerators for various menu items

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Language Language Language Language

Gets or sets localization/globalization language information that applies to a FrameworkElement, and also to all child elements of the current FrameworkElement in the object representation and in UI.

(Inherited from FrameworkElement)

LanguageProperty LanguageProperty LanguageProperty LanguageProperty

Identifies the Language dependency property.

(Inherited from FrameworkElement)

Lights Lights Lights Lights

Gets the collection of XamlLight objects attached to this element.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

LightsProperty LightsProperty LightsProperty LightsProperty

Identifies the Lights dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

LosingFocusEvent LosingFocusEvent LosingFocusEvent LosingFocusEvent

Gets the identifier for the LosingFocus routed event.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

ManipulationCompletedEvent ManipulationCompletedEvent ManipulationCompletedEvent ManipulationCompletedEvent

Gets the identifier for the ManipulationCompleted routed event.

(Inherited from UIElement)

ManipulationDeltaEvent ManipulationDeltaEvent ManipulationDeltaEvent ManipulationDeltaEvent

Gets the identifier for the ManipulationDelta routed event.

(Inherited from UIElement)

ManipulationInertiaStartingEvent ManipulationInertiaStartingEvent ManipulationInertiaStartingEvent ManipulationInertiaStartingEvent

Gets the identifier for the ManipulationInertiaStarting routed event.

(Inherited from UIElement)

ManipulationMode ManipulationMode ManipulationMode ManipulationMode

Gets or sets the ManipulationModes value used for UIElement behavior and interaction with gestures. Setting this value enables handling the manipulation events from this element in app code.

(Inherited from UIElement)

ManipulationModeProperty ManipulationModeProperty ManipulationModeProperty ManipulationModeProperty

Identifies the ManipulationMode dependency property.

(Inherited from UIElement)

ManipulationStartedEvent ManipulationStartedEvent ManipulationStartedEvent ManipulationStartedEvent

Gets the identifier for the ManipulationStarted routed event.

(Inherited from UIElement)

ManipulationStartingEvent ManipulationStartingEvent ManipulationStartingEvent ManipulationStartingEvent

Gets the identifier for the ManipulationStarting routed event.

(Inherited from UIElement)

Margin Margin Margin Margin

Gets or sets the outer margin of a FrameworkElement.

(Inherited from FrameworkElement)

MarginProperty MarginProperty MarginProperty MarginProperty

Identifies the Margin dependency property.

(Inherited from FrameworkElement)

Markers Markers Markers Markers

Gets the collection of timeline markers associated with the currently loaded media file.

public : TimelineMarkerCollection Markers { get; }
TimelineMarkerCollection Markers();
public TimelineMarkerCollection Markers { get; }
Public ReadOnly Property Markers As TimelineMarkerCollection
Value
TimelineMarkerCollection TimelineMarkerCollection

The collection of timeline markers (represented as TimelineMarker objects) associated with the currently loaded media file. The default is an empty collection.

Examples

The following example creates a MediaElement object and responds to its MarkerReached event. Each time a timeline marker is reached, the example displays the timeline marker's Time, Type, and Text values.

<MediaElement Name="Media" Source="video.mp4" MarkerReached="Media_MarkerReached" />
<TextBlock Name="txOutput" />
private void Media_MarkerReached(object sender, TimelineMarkerRoutedEventArgs e)
{
    txOutput.Text =
        string.Format("{0},{1},{2}", e.Marker.Time, e.Marker.Text, e.Marker.Type);
}

Remarks

A timeline marker is metadata associated with a particular point in a media file. These markers are usually created ahead of time and stored in the media file itself. They are typically used to name different scenes in a video or provide scripting cues. By handling the MediaElement object's MarkerReached event or by accessing the MediaElement object's Markers property, you can use timeline markers to trigger actions or enable users to seek to selected positions in the media file.

MaxHeight MaxHeight MaxHeight MaxHeight

Gets or sets the maximum height constraint of a FrameworkElement.

(Inherited from FrameworkElement)

MaxHeightProperty MaxHeightProperty MaxHeightProperty MaxHeightProperty

Identifies the MaxHeight dependency property.

(Inherited from FrameworkElement)

MaxWidth MaxWidth MaxWidth MaxWidth

Gets or sets the maximum width constraint of a FrameworkElement.

(Inherited from FrameworkElement)

MaxWidthProperty MaxWidthProperty MaxWidthProperty MaxWidthProperty

Identifies the MaxWidth dependency property.

(Inherited from FrameworkElement)

MinHeight MinHeight MinHeight MinHeight

Gets or sets the minimum height constraint of a FrameworkElement.

(Inherited from FrameworkElement)

MinHeightProperty MinHeightProperty MinHeightProperty MinHeightProperty

Identifies the MinHeight dependency property.

(Inherited from FrameworkElement)

MinWidth MinWidth MinWidth MinWidth

Gets or sets the minimum width constraint of a FrameworkElement.

(Inherited from FrameworkElement)

MinWidthProperty MinWidthProperty MinWidthProperty MinWidthProperty

Identifies the MinWidth dependency property.

(Inherited from FrameworkElement)

Name Name Name Name

Gets or sets the identifying name of the object. When a XAML processor creates the object tree from XAML markup, run-time code can refer to the XAML-declared object by this name.

(Inherited from FrameworkElement)

NameProperty NameProperty NameProperty NameProperty

Identifies the Name dependency property.

(Inherited from FrameworkElement)

NaturalDuration NaturalDuration NaturalDuration NaturalDuration

Gets the duration of the media file currently opened.

public : Duration NaturalDuration { get; }
Duration NaturalDuration();
public Duration NaturalDuration { get; }
Public ReadOnly Property NaturalDuration As Duration
Value
Duration Duration

The natural duration of the media. The default value is a Duration structure that evaluates as Automatic, which is the value held if you query this property before MediaOpened.

Remarks

A Duration value has a TimeSpan component.

C# or Microsoft Visual Basic You can use utility methods of System.TimeSpan to get the duration components in whatever format you want. For example you can get TimeSpan.Hours, TimeSpan.Minutes and TimeSpan.Seconds separately.

Visual C++ component extensions (C++/CX) The data value of a Duration is a property named TimeSpan. This has a TimeSpan structure value, and that structure has a field named Duration that reports the duration as an int64 that counts in 100-nanosecond units. TimeSpan doesn't have any methods for getting components of the time in hours:minutes:seconds format.

For more info, see Remarks in the Duration reference topic.

NaturalDurationProperty NaturalDurationProperty NaturalDurationProperty NaturalDurationProperty

Identifies the NaturalDuration dependency property.

public : static DependencyProperty NaturalDurationProperty { get; }
static DependencyProperty NaturalDurationProperty();
public static DependencyProperty NaturalDurationProperty { get; }
Public Static ReadOnly Property NaturalDurationProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the NaturalDuration dependency property.

NaturalVideoHeight NaturalVideoHeight NaturalVideoHeight NaturalVideoHeight

Gets the height of the video associated with the media.

public : int NaturalVideoHeight { get; }
int32_t NaturalVideoHeight();
public int NaturalVideoHeight { get; }
Public ReadOnly Property NaturalVideoHeight As int
Value
int int

The height of the video that is associated with the media, in pixels. Audio files return 0. The default is 0.

NaturalVideoHeightProperty NaturalVideoHeightProperty NaturalVideoHeightProperty NaturalVideoHeightProperty

Identifies the NaturalVideoHeight dependency property.

public : static DependencyProperty NaturalVideoHeightProperty { get; }
static DependencyProperty NaturalVideoHeightProperty();
public static DependencyProperty NaturalVideoHeightProperty { get; }
Public Static ReadOnly Property NaturalVideoHeightProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the NaturalVideoHeight dependency property.

NaturalVideoWidth NaturalVideoWidth NaturalVideoWidth NaturalVideoWidth

Gets the width of the video associated with the media.

public : int NaturalVideoWidth { get; }
int32_t NaturalVideoWidth();
public int NaturalVideoWidth { get; }
Public ReadOnly Property NaturalVideoWidth As int
Value
int int

The width of the video associated with the media. The default is 0.

NaturalVideoWidthProperty NaturalVideoWidthProperty NaturalVideoWidthProperty NaturalVideoWidthProperty

Identifies the NaturalVideoWidth dependency property.

public : static DependencyProperty NaturalVideoWidthProperty { get; }
static DependencyProperty NaturalVideoWidthProperty();
public static DependencyProperty NaturalVideoWidthProperty { get; }
Public Static ReadOnly Property NaturalVideoWidthProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the NaturalVideoWidth dependency property.

NoFocusCandidateFoundEvent NoFocusCandidateFoundEvent NoFocusCandidateFoundEvent NoFocusCandidateFoundEvent

Gets the identifier for the NoFocusCandidateFound routed event.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Opacity Opacity Opacity Opacity

Gets or sets the degree of the object's opacity.

(Inherited from UIElement)

OpacityProperty OpacityProperty OpacityProperty OpacityProperty

Identifies the IsHitTestVisible dependency property.

(Inherited from UIElement)

Parent Parent Parent Parent

Gets the parent object of this FrameworkElement in the object tree.

(Inherited from FrameworkElement)

PlayToPreferredSourceUri PlayToPreferredSourceUri PlayToPreferredSourceUri PlayToPreferredSourceUri

Gets or sets the path to the preferred media source which enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server.

public : Uri PlayToPreferredSourceUri { get; set; }
Uri PlayToPreferredSourceUri(); void PlayToPreferredSourceUri(Uri playtopreferredsourceuri);
public Uri PlayToPreferredSourceUri { get; set; }
Public ReadWrite Property PlayToPreferredSourceUri As Uri
<MediaElement PlayToPreferredSourceUri="uri" />
Value
Uri Uri

The path to the preferred media source.

Examples

Here is some code that shows how to set up Play To by reference.

<MediaElement Source="http://www.contoso.com/videos/video.mp4" 
   PlayToPreferredSourceUri="http://www.contoso.com/catalogid=1234">
</MediaElement>
MediaElement video = new MediaElement();

video.Source = 
    new Uri("http://www.contoso.com/videos/video.mp4");

video.PlayToPreferredSourceUri = 
    new Uri("http://www.contoso.com/catalogid=1234"); 
auto video = ref new Windows::UI::Xaml::Controls::MediaElement();

video->Source = 
   ref new Windows::Foundation::Uri("http://www.contoso.com/videos/video.mp4");

video->PlayToPreferredSourceUri = 
   ref new Windows::Foundation::Uri("http://www.contoso.com/catalogid=1234");

Remarks

PlayToSource.PreferredSourceUri enables Play To by reference. This allows streaming content on the Play To target device from a different location, such as a cloud media server. This enables web pages and UWP app to play Digital Rights Management (DRM) protected content. The app specifies a preferred Uniform Resource Identifier (URI) that will be sent to the Play To target device. This Uniform Resource Identifier (URI) can point to a cloud based media server. If the PlayToSource.PreferredSourceUri value is present, the Play To target device can stream content directly from the cloud, which can be Digital Rights Management (DRM) protected, instead of streaming content from the Windows machine which must be unprotected content.

A forward slash ("/") is appended to the Uniform Resource Identifier (URI) string when it is sent over the network to a Play To device. This is done to conform to Uniform Resource Identifier (URI) standards.

PlayToPreferredSourceUriProperty PlayToPreferredSourceUriProperty PlayToPreferredSourceUriProperty PlayToPreferredSourceUriProperty

Identifies the PlayToPreferredSourceUri dependency property.

public : static DependencyProperty PlayToPreferredSourceUriProperty { get; }
static DependencyProperty PlayToPreferredSourceUriProperty();
public static DependencyProperty PlayToPreferredSourceUriProperty { get; }
Public Static ReadOnly Property PlayToPreferredSourceUriProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the PlayToPreferredSourceUri dependency property.

PlayToSource PlayToSource PlayToSource PlayToSource

Gets the information that is transmitted if the MediaElement is used for a "PlayTo" scenario.

public : PlayToSource PlayToSource { get; }
PlayToSource PlayToSource();
public PlayToSource PlayToSource { get; }
Public ReadOnly Property PlayToSource As PlayToSource
Value
PlayToSource PlayToSource

A reference object that carries the "PlayTo" source information.

PlayToSourceProperty PlayToSourceProperty PlayToSourceProperty PlayToSourceProperty

Identifies the PlayToSource dependency property.

public : static DependencyProperty PlayToSourceProperty { get; }
static DependencyProperty PlayToSourceProperty();
public static DependencyProperty PlayToSourceProperty { get; }
Public Static ReadOnly Property PlayToSourceProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the PlayToSource dependency property.

PlaybackRate PlaybackRate PlaybackRate PlaybackRate

Gets or sets the playback rate ratio for the media engine.

public : double PlaybackRate { get; set; }
double PlaybackRate(); void PlaybackRate(double playbackrate);
public double PlaybackRate { get; set; }
Public ReadWrite Property PlaybackRate As double
<MediaElement PlaybackRate="double"/>
Value
double double

The playback rate ratio for the media. A value of 1.0 is the normal playback speed. Value can be negative to play backwards.

Remarks

The current PlaybackRate is set to the value of DefaultPlaybackRate whenever Play is called. So setting DefaultPlaybackRate to a different value has no effect until Play is called.

To set a rate that will persist throughout the lifetime of the MediaElement, use DefaultPlaybackRate. Once playback ends, due to the MediaEnded event being raised or if Pause or Stop are called, the PlaybackRate will be effectively lost.

PlaybackRateProperty PlaybackRateProperty PlaybackRateProperty PlaybackRateProperty

Identifies the PlaybackRate dependency property.

public : static DependencyProperty PlaybackRateProperty { get; }
static DependencyProperty PlaybackRateProperty();
public static DependencyProperty PlaybackRateProperty { get; }
Public Static ReadOnly Property PlaybackRateProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the PlaybackRate dependency property.

PointerCanceledEvent PointerCanceledEvent PointerCanceledEvent PointerCanceledEvent

Gets the identifier for the PointerCanceled routed event.

(Inherited from UIElement)

PointerCaptureLostEvent PointerCaptureLostEvent PointerCaptureLostEvent PointerCaptureLostEvent

Gets the identifier for the PointerCaptureLost routed event.

(Inherited from UIElement)

PointerCaptures PointerCaptures PointerCaptures PointerCaptures

Gets the set of all captured pointers, represented as Pointer values.

(Inherited from UIElement)

PointerCapturesProperty PointerCapturesProperty PointerCapturesProperty PointerCapturesProperty

Identifies the PointerCaptures dependency property.

(Inherited from UIElement)

PointerEnteredEvent PointerEnteredEvent PointerEnteredEvent PointerEnteredEvent

Gets the identifier for the PointerEntered routed event.

(Inherited from UIElement)

PointerExitedEvent PointerExitedEvent PointerExitedEvent PointerExitedEvent

Gets the identifier for the PointerExited routed event.

(Inherited from UIElement)

PointerMovedEvent PointerMovedEvent PointerMovedEvent PointerMovedEvent

Gets the identifier for the PointerMoved routed event.

(Inherited from UIElement)

PointerPressedEvent PointerPressedEvent PointerPressedEvent PointerPressedEvent

Gets the identifier for the PointerPressed routed event.

(Inherited from UIElement)

PointerReleasedEvent PointerReleasedEvent PointerReleasedEvent PointerReleasedEvent

Gets the identifier for the PointerReleased routed event.

(Inherited from UIElement)

PointerWheelChangedEvent PointerWheelChangedEvent PointerWheelChangedEvent PointerWheelChangedEvent

Gets the identifier for the PointerWheelChanged routed event.

(Inherited from UIElement)

Position Position Position Position

Gets or sets the current position of progress through the media's playback time.

public : TimeSpan Position { get; set; }
TimeSpan Position(); void Position(TimeSpan position);
public TimeSpan Position { get; set; }
Public ReadWrite Property Position As TimeSpan
Value
TimeSpan TimeSpan

The amount of time since the beginning of the media. The default is a TimeSpan with value "0:0:0".

Remarks

Set this property to set a specific start-play position within the media.

A TimeSpan is represented as different types depending on the programming language you are using.

C# or Microsoft Visual Basic Use a System.TimeSpan structure. System.TimeSpan has utility members such as Parse(String) that make it easy to create, change or compare time values.

Visual C++ component extensions (C++/CX) Use a Windows::Foundation::TimeSpan structure. This structure has only one field member (Duration), which measures by 100-nanosecond units. If you intend to display a Position value in an hours:minutes:seconds format, you'll have to write your own logic for converting to that format from the Duration units.

If you are not sure of the current media source loaded as MediaElement.Source, always check CanSeek first. A streaming media source results in the MediaElement reporting CanSeek as false, and in this case you cannot use Position to set the playback point.

If Position is settable, then these value constraints apply:

Notes on XAML syntax

Setting a Position value in XAML is technically possible but not common. If you do set a Position in XAML, simulate the "FromString" type conversion behavior for a TimeSpan, in other words specify the value in the form "HH:MM:SS".

See Also

PositionProperty PositionProperty PositionProperty PositionProperty

Identifies the Position dependency property.

public : static DependencyProperty PositionProperty { get; }
static DependencyProperty PositionProperty();
public static DependencyProperty PositionProperty { get; }
Public Static ReadOnly Property PositionProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier the Position dependency property.

PosterSource PosterSource PosterSource PosterSource

Gets or sets the image source that is used for a placeholder image during MediaElement loading transition states.

public : ImageSource PosterSource { get; set; }
ImageSource PosterSource(); void PosterSource(ImageSource postersource);
public ImageSource PosterSource { get; set; }
Public ReadWrite Property PosterSource As ImageSource
<MediaElement PosterSource="imageUri" />
Value
ImageSource ImageSource

An image source for a transition ImageBrush that is applied to the MediaElement content area.

Remarks

A PosterSource is an image, such as a album cover or movie poster, that is displayed in place of video. It provides your MediaElement with a visual representation before the media is loaded, or when the media is audio only.

The PosterSource is displayed in the following situations:

  • When a valid source is not set. For example, Source is not set, Source is set to Null, or the source is invalid (as is the case when a MediaFailed event fires).
  • While media is loading. For example, a valid source is set, but the MediaOpened event has not fired yet.
  • While media is streaming to another device.
  • When the media is audio only.

PosterSourceProperty PosterSourceProperty PosterSourceProperty PosterSourceProperty

Identifies the PosterSource dependency property.

public : static DependencyProperty PosterSourceProperty { get; }
static DependencyProperty PosterSourceProperty();
public static DependencyProperty PosterSourceProperty { get; }
Public Static ReadOnly Property PosterSourceProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the PosterSource dependency property.

PreviewKeyDownEvent PreviewKeyDownEvent PreviewKeyDownEvent PreviewKeyDownEvent

Gets the identifier for the PreviewKeyDown routed event.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

PreviewKeyUpEvent PreviewKeyUpEvent PreviewKeyUpEvent PreviewKeyUpEvent

Gets the identifier for the PreviewKeyUp routed event.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Projection Projection Projection Projection

Gets or sets the perspective projection (3-D effect) to apply when rendering this element.

(Inherited from UIElement)

ProjectionProperty ProjectionProperty ProjectionProperty ProjectionProperty

Identifies the Projection dependency property.

(Inherited from UIElement)

ProtectionManager ProtectionManager ProtectionManager ProtectionManager

Gets or sets the dedicated object for media content protection that is associated with this MediaElement.

public : MediaProtectionManager ProtectionManager { get; set; }
MediaProtectionManager ProtectionManager(); void ProtectionManager(MediaProtectionManager protectionmanager);
public MediaProtectionManager ProtectionManager { get; set; }
Public ReadWrite Property ProtectionManager As MediaProtectionManager
Value
MediaProtectionManager MediaProtectionManager

The dedicated object for media content protection.

Remarks

See the PlayReady sample for for an example of using ProtectionManager.

ProtectionManagerProperty ProtectionManagerProperty ProtectionManagerProperty ProtectionManagerProperty

Identifies the ProtectionManager dependency property.

public : static DependencyProperty ProtectionManagerProperty { get; }
static DependencyProperty ProtectionManagerProperty();
public static DependencyProperty ProtectionManagerProperty { get; }
Public Static ReadOnly Property ProtectionManagerProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the ProtectionManager dependency property.

RealTimePlayback RealTimePlayback RealTimePlayback RealTimePlayback

Gets or sets a value that configures the MediaElement for real-time communications scenarios.

public : Platform::Boolean RealTimePlayback { get; set; }
bool RealTimePlayback(); void RealTimePlayback(bool realtimeplayback);
public bool RealTimePlayback { get; set; }
Public ReadWrite Property RealTimePlayback As bool
<MediaElement RealTimePlayback="bool" />
Value
bool bool

true to configure for real-time communications. false to not configure the MediaElement for real-time communications.

Remarks

Configuring for real-time playback changes the internal update logic to place higher emphasis on video refresh from available samples, and also restricts playback to natural 1x speed. Setting the property requires an internal reconstruction of the backing media engine.

See Also

RealTimePlaybackProperty RealTimePlaybackProperty RealTimePlaybackProperty RealTimePlaybackProperty

Identifies the RealTimePlayback dependency property.

public : static DependencyProperty RealTimePlaybackProperty { get; }
static DependencyProperty RealTimePlaybackProperty();
public static DependencyProperty RealTimePlaybackProperty { get; }
Public Static ReadOnly Property RealTimePlaybackProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the RealTimePlayback dependency property.

RenderSize RenderSize RenderSize RenderSize

Gets the final render size of a UIElement. Use is not recommended, see Remarks.

(Inherited from UIElement)

RenderTransform RenderTransform RenderTransform RenderTransform

Gets or sets transform information that affects the rendering position of a UIElement.

(Inherited from UIElement)

RenderTransformOrigin RenderTransformOrigin RenderTransformOrigin RenderTransformOrigin

Gets or sets the origin point of any possible render transform declared by RenderTransform, relative to the bounds of the UIElement.

(Inherited from UIElement)

RenderTransformOriginProperty RenderTransformOriginProperty RenderTransformOriginProperty RenderTransformOriginProperty

Identifies the RenderTransformOrigin dependency property.

(Inherited from UIElement)

RenderTransformProperty RenderTransformProperty RenderTransformProperty RenderTransformProperty

Identifies the RenderTransform dependency property.

(Inherited from UIElement)

RequestedTheme RequestedTheme RequestedTheme RequestedTheme

Gets or sets the UI theme that is used by the UIElement (and its child elements) for resource determination. The UI theme you specify with RequestedTheme can override the app-level RequestedTheme.

(Inherited from FrameworkElement)

RequestedThemeProperty RequestedThemeProperty RequestedThemeProperty RequestedThemeProperty

Identifies the RequestedTheme dependency property.

(Inherited from FrameworkElement)

Resources Resources Resources Resources

Gets the locally defined resource dictionary. In XAML, you can establish resource items as child object elements of a frameworkElement.Resources property element, through XAML implicit collection syntax.

(Inherited from FrameworkElement)

RightTappedEvent RightTappedEvent RightTappedEvent RightTappedEvent

Gets the identifier for the RightTapped routed event.

(Inherited from UIElement)

Source Source Source Source

Gets or sets a media source on the MediaElement.

public : Uri Source { get; set; }
Uri Source(); void Source(Uri source);
public Uri Source { get; set; }
Public ReadWrite Property Source As Uri
<MediaElement Source="uri" .../>
Value
Uri Uri

The source of the element, as an object describing a Uniform Resource Identifier (URI). The default is null.

SourceProperty SourceProperty SourceProperty SourceProperty

Identifies the Source dependency property.

public : static DependencyProperty SourceProperty { get; }
static DependencyProperty SourceProperty();
public static DependencyProperty SourceProperty { get; }
Public Static ReadOnly Property SourceProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the Source dependency property.

Stereo3DVideoPackingMode Stereo3DVideoPackingMode Stereo3DVideoPackingMode Stereo3DVideoPackingMode

Gets or sets an enumeration value that determines the stereo 3-D video frame-packing mode for the current media source.

public : Stereo3DVideoPackingMode Stereo3DVideoPackingMode { get; set; }
Stereo3DVideoPackingMode Stereo3DVideoPackingMode(); void Stereo3DVideoPackingMode(Stereo3DVideoPackingMode stereo3dvideopackingmode);
public Stereo3DVideoPackingMode Stereo3DVideoPackingMode { get; set; }
Public ReadWrite Property Stereo3DVideoPackingMode As Stereo3DVideoPackingMode
<MediaElement Stereo3DVideoPackingMode="stereo3DVideoPackingModeMemberName" .../>
Value
Stereo3DVideoPackingMode Stereo3DVideoPackingMode

A value of the enumeration. See Remarks.

Examples

<MediaElement x:Name="me1" Stereo3DVideoPackingMode="TopBottom" Stereo3DVideoRenderMode="Stereo"/>

Remarks

The Stereo3DVideoPackingMode default is to allow the system to determine the packing mode from the metadata of the video content. In order to reset a Stereo3DVideoPackingMode value once it has been set, use ClearValue. Stereo3DVideoPackingMode is used in conjunction with Stereo3DVideoRenderMode to display 3-D content.

Stereo3DVideoPackingModeProperty Stereo3DVideoPackingModeProperty Stereo3DVideoPackingModeProperty Stereo3DVideoPackingModeProperty

Identifies the Stereo3DVideoPackingMode dependency property.

public : static DependencyProperty Stereo3DVideoPackingModeProperty { get; }
static DependencyProperty Stereo3DVideoPackingModeProperty();
public static DependencyProperty Stereo3DVideoPackingModeProperty { get; }
Public Static ReadOnly Property Stereo3DVideoPackingModeProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the Stereo3DVideoPackingMode dependency property.

Stereo3DVideoRenderMode Stereo3DVideoRenderMode Stereo3DVideoRenderMode Stereo3DVideoRenderMode

Gets or sets an enumeration value that determines the stereo 3-D video render mode for the current media source.

public : Stereo3DVideoRenderMode Stereo3DVideoRenderMode { get; set; }
Stereo3DVideoRenderMode Stereo3DVideoRenderMode(); void Stereo3DVideoRenderMode(Stereo3DVideoRenderMode stereo3dvideorendermode);
public Stereo3DVideoRenderMode Stereo3DVideoRenderMode { get; set; }
Public ReadWrite Property Stereo3DVideoRenderMode As Stereo3DVideoRenderMode
<MediaElement Stereo3DVideoRenderMode="stereo3DVideoRenderModeMemberName" .../>
Value
Stereo3DVideoRenderMode Stereo3DVideoRenderMode

A value of the enumeration.

Examples

<MediaElement x:Name="me1" Stereo3DVideoPackingMode="TopBottom" Stereo3DVideoRenderMode="Stereo"/>

Remarks

IsStereo3DVideo is an evaluated read-only property that is based on Stereo3DVideoRenderMode.

Set Stereo3DVideoRenderMode to Stereo when you want to enable the MediaElement to play 3D video. The API works in conjunction with Stereo3DVideoPackingMode, which lets you set the packing mode or allows the sub systems to infer it from the video file

Stereo3DVideoRenderModeProperty Stereo3DVideoRenderModeProperty Stereo3DVideoRenderModeProperty Stereo3DVideoRenderModeProperty

Identifies the Stereo3DVideoRenderMode dependency property.

public : static DependencyProperty Stereo3DVideoRenderModeProperty { get; }
static DependencyProperty Stereo3DVideoRenderModeProperty();
public static DependencyProperty Stereo3DVideoRenderModeProperty { get; }
Public Static ReadOnly Property Stereo3DVideoRenderModeProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the Stereo3DVideoRenderMode dependency property.

Stretch Stretch Stretch Stretch

Gets or sets a value that describes how an MediaElement should be stretched to fill the destination rectangle.

public : Stretch Stretch { get; set; }
Stretch Stretch(); void Stretch(Stretch stretch);
public Stretch Stretch { get; set; }
Public ReadWrite Property Stretch As Stretch
<MediaElement Stretch="stretchMemberName" />
Value
Stretch Stretch

A value of the Stretch enumeration that specifies how the source visual media is rendered. The default value is Uniform.

Examples

Here is some code that shows how to create a zoom effect, similar to msZoom in Windows app using JavaScript. The MediaElement content will fill up the entire layout space while preserving the aspect ratio of the content. This could result in cropping if the aspect ratio of the content is not the same as the layout space.

private void ToggleZoom(MediaElement media)
{
    if (media.Stretch != Stretch.UniformToFill)
    {
        // zoom
        media.Stretch = Stretch.UniformToFill;
    }
    else
    {
        // unzoom
        media.Stretch = Stretch.Uniform;
    }
}

Remarks

Here's what the Stretch values represent for MediaElement content:

  • None: The original size of the content is preserved.
  • Fill: The content is resized to fill the destination dimensions. The aspect ratio of the video is not preserved.
  • UniformToFill: Uniformly stretches the MediaElement to fill the available layout space while preserving the aspect ratio of the content. If the aspect ratio of the destination rectangle differs from the source, the source content is clipped to fit the destination dimensions.
  • Uniform: Uniformly stretches the MediaElement to fill the layout space while preserve the aspect ratio of the image. This will ensure that the entire image is displayed, undistorted and not cropped. This may result in letterboxing or pillarboxing on the top or sides of the image, depending on the aspect ratio of the content.
See Also

StretchProperty StretchProperty StretchProperty StretchProperty

Identifies the Stretch dependency property.

public : static DependencyProperty StretchProperty { get; }
static DependencyProperty StretchProperty();
public static DependencyProperty StretchProperty { get; }
Public Static ReadOnly Property StretchProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the Stretch dependency property.

Style Style Style Style

Gets or sets an instance Style that is applied for this object during layout and rendering.

(Inherited from FrameworkElement)

StyleProperty StyleProperty StyleProperty StyleProperty

Identifies the Style dependency property.

(Inherited from FrameworkElement)

TabFocusNavigation TabFocusNavigation TabFocusNavigation TabFocusNavigation

Gets or sets a value that modifies how tabbing and TabIndex work for this control.

Note

For Windows 10 Creators Update (build 10.0.15063) and newer, use this property of the UIElement base class instead of the TabNavigation property of a Control object.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

TabFocusNavigationProperty TabFocusNavigationProperty TabFocusNavigationProperty TabFocusNavigationProperty

Identifies the TabFocusNavigation dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Tag Tag Tag Tag

Gets or sets an arbitrary object value that can be used to store custom information about this object.

(Inherited from FrameworkElement)

TagProperty TagProperty TagProperty TagProperty

Identifies the Tag dependency property.

(Inherited from FrameworkElement)

TappedEvent TappedEvent TappedEvent TappedEvent

Gets the identifier for the Tapped routed event.

(Inherited from UIElement)

Transform3D Transform3D Transform3D Transform3D

Gets or sets the 3-D transform effect to apply when rendering this element.

(Inherited from UIElement)

Transform3DProperty Transform3DProperty Transform3DProperty Transform3DProperty

Identifies the Transform3D dependency property.

(Inherited from UIElement)

Transitions Transitions Transitions Transitions

Gets or sets the collection of Transition style elements that apply to a UIElement.

(Inherited from UIElement)

TransitionsProperty TransitionsProperty TransitionsProperty TransitionsProperty

Identifies the Transitions dependency property.

(Inherited from UIElement)

TransportControls TransportControls TransportControls TransportControls

Gets or sets the transport controls for the media.

public : MediaTransportControls TransportControls { get; set; }
MediaTransportControls TransportControls(); void TransportControls(MediaTransportControls transportcontrols);
public MediaTransportControls TransportControls { get; set; }
Public ReadWrite Property TransportControls As MediaTransportControls
Value
MediaTransportControls MediaTransportControls

The transport controls for the media.

Triggers Triggers Triggers Triggers

Gets the collection of triggers for animations that are defined for a FrameworkElement. Not commonly used. See Remarks.

(Inherited from FrameworkElement)

UseLayoutRounding UseLayoutRounding UseLayoutRounding UseLayoutRounding

Gets or sets a value that determines whether rendering for the object and its visual subtree should use rounding behavior that aligns rendering to whole pixels.

(Inherited from UIElement)

UseLayoutRoundingProperty UseLayoutRoundingProperty UseLayoutRoundingProperty UseLayoutRoundingProperty

Identifies the UseLayoutRounding dependency property.

(Inherited from UIElement)

VerticalAlignment VerticalAlignment VerticalAlignment VerticalAlignment

Gets or sets the vertical alignment characteristics that are applied to a FrameworkElement when it is composed in a parent object such as a panel or items control.

(Inherited from FrameworkElement)

VerticalAlignmentProperty VerticalAlignmentProperty VerticalAlignmentProperty VerticalAlignmentProperty

Identifies the VerticalAlignment dependency property.

(Inherited from FrameworkElement)

Visibility Visibility Visibility Visibility

Gets or sets the visibility of a UIElement. A UIElement that is not visible is not rendered and does not communicate its desired size to layout.

(Inherited from UIElement)

VisibilityProperty VisibilityProperty VisibilityProperty VisibilityProperty

Identifies the Visibility dependency property.

(Inherited from UIElement)

Volume Volume Volume Volume

Gets or sets the media's volume.

public : double Volume { get; set; }
double Volume(); void Volume(double volume);
public double Volume { get; set; }
Public ReadWrite Property Volume As double
<MediaElement Volume="double"/>
Value
double double

The media's volume represented on a linear scale between 0 and 1. The default is 0.5.

VolumeProperty VolumeProperty VolumeProperty VolumeProperty

Identifies the Volume dependency property.

public : static DependencyProperty VolumeProperty { get; }
static DependencyProperty VolumeProperty();
public static DependencyProperty VolumeProperty { get; }
Public Static ReadOnly Property VolumeProperty As DependencyProperty
Value
DependencyProperty DependencyProperty

The identifier for the Volume dependency property.

Width Width Width Width

Gets or sets the width of a FrameworkElement.

(Inherited from FrameworkElement)

WidthProperty WidthProperty WidthProperty WidthProperty

Identifies the Width dependency property.

(Inherited from FrameworkElement)

XYFocusDownNavigationStrategy XYFocusDownNavigationStrategy XYFocusDownNavigationStrategy XYFocusDownNavigationStrategy

Gets or sets a value that specifies the strategy used to determine the target element of a down navigation.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

XYFocusDownNavigationStrategyProperty XYFocusDownNavigationStrategyProperty XYFocusDownNavigationStrategyProperty XYFocusDownNavigationStrategyProperty

Identifies the XYFocusDownNavigationStrategy dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

XYFocusKeyboardNavigation XYFocusKeyboardNavigation XYFocusKeyboardNavigation XYFocusKeyboardNavigation

Gets or sets a value that enables or disables navigation using the keyboard directional arrows.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

XYFocusKeyboardNavigationProperty XYFocusKeyboardNavigationProperty XYFocusKeyboardNavigationProperty XYFocusKeyboardNavigationProperty

Identifies the XYFocusKeyboardNavigation dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

XYFocusLeftNavigationStrategy XYFocusLeftNavigationStrategy XYFocusLeftNavigationStrategy XYFocusLeftNavigationStrategy

Gets or sets a value that specifies the strategy used to determine the target element of a left navigation.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

XYFocusLeftNavigationStrategyProperty XYFocusLeftNavigationStrategyProperty XYFocusLeftNavigationStrategyProperty XYFocusLeftNavigationStrategyProperty

Identifies the XYFocusLeftNavigationStrategy dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

XYFocusRightNavigationStrategy XYFocusRightNavigationStrategy XYFocusRightNavigationStrategy XYFocusRightNavigationStrategy

Gets or sets a value that specifies the strategy used to determine the target element of a right navigation.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

XYFocusRightNavigationStrategyProperty XYFocusRightNavigationStrategyProperty XYFocusRightNavigationStrategyProperty XYFocusRightNavigationStrategyProperty

Identifies the XYFocusRightNavigationStrategy dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

XYFocusUpNavigationStrategy XYFocusUpNavigationStrategy XYFocusUpNavigationStrategy XYFocusUpNavigationStrategy

Gets or sets a value that specifies the strategy used to determine the target element of an up navigation.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

XYFocusUpNavigationStrategyProperty XYFocusUpNavigationStrategyProperty XYFocusUpNavigationStrategyProperty XYFocusUpNavigationStrategyProperty

Identifies the XYFocusUpNavigationStrategy dependency property.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Methods

AddAudioEffect(String, Boolean, IPropertySet) AddAudioEffect(String, Boolean, IPropertySet) AddAudioEffect(String, Boolean, IPropertySet) AddAudioEffect(String, Boolean, IPropertySet)

Applies an audio effect to playback. Takes effect for the next source that is set on this MediaElement.

public : void AddAudioEffect(Platform::String effectID, bool effectOptional, IPropertySet effectConfiguration)
void AddAudioEffect(winrt::hstring effectID, bool effectOptional, IPropertySet effectConfiguration) const;
public void AddAudioEffect(String effectID, Boolean effectOptional, IPropertySet effectConfiguration)
Public Function AddAudioEffect(effectID As String, effectOptional As Boolean, effectConfiguration As IPropertySet) As void
Parameters
effectID
String String

The identifier for the desired effect.

effectOptional
Boolean Boolean

true if the effect shouldn't block playback when the effect can't be used at run time. false if the effect should block playback when the effect can't be used at run time.

effectConfiguration
IPropertySet IPropertySet

A property set that transmits property values to specific effects as selected by effectID.

Remarks

The audio effects needs to be added before loading the source. Otherwise, it will be applied for the next source that is set on this MediaElement.

AddHandler(RoutedEvent,Object,Boolean) AddHandler(RoutedEvent,Object,Boolean) AddHandler(RoutedEvent,Object,Boolean) AddHandler(RoutedEvent,Object,Boolean)

Adds a routed event handler for a specified routed event, adding the handler to the handler collection on the current element. Specify handledEventsToo as true to have the provided handler be invoked even if the event is handled elsewhere.

(Inherited from UIElement)

AddVideoEffect(String, Boolean, IPropertySet) AddVideoEffect(String, Boolean, IPropertySet) AddVideoEffect(String, Boolean, IPropertySet) AddVideoEffect(String, Boolean, IPropertySet)

Applies a video effect to playback. Takes effect for the next source that is set on this MediaElement.

public : void AddVideoEffect(Platform::String effectID, bool effectOptional, IPropertySet effectConfiguration)
void AddVideoEffect(winrt::hstring effectID, bool effectOptional, IPropertySet effectConfiguration) const;
public void AddVideoEffect(String effectID, Boolean effectOptional, IPropertySet effectConfiguration)
Public Function AddVideoEffect(effectID As String, effectOptional As Boolean, effectConfiguration As IPropertySet) As void
Parameters
effectID
String String

The identifier for the desired effect.

effectOptional
Boolean Boolean

true if the effect shouldn't block playback when the effect can't be used at run time. false if the effect should block playback when the effect can't be used at run time.

effectConfiguration
IPropertySet IPropertySet

A property set that transmits property values to specific effects as selected by effectID.

Arrange(Rect) Arrange(Rect) Arrange(Rect) Arrange(Rect)

Positions child objects and determines a size for a UIElement. Parent objects that implement custom layout for their child elements should call this method from their layout override implementations to form a recursive layout update.

(Inherited from UIElement)

ArrangeOverride(Size) ArrangeOverride(Size) ArrangeOverride(Size) ArrangeOverride(Size)

Provides the behavior for the "Arrange" pass of layout. Classes can override this method to define their own "Arrange" pass behavior.

(Inherited from FrameworkElement)

CanPlayType(String) CanPlayType(String) CanPlayType(String) CanPlayType(String)

Returns an enumeration value that describes the likelihood that the current MediaElement and its client configuration can play that media source.

public : MediaCanPlayResponse CanPlayType(Platform::String type)
MediaCanPlayResponse CanPlayType(winrt::hstring type) const;
public MediaCanPlayResponse CanPlayType(String type)
Public Function CanPlayType(type As String) As MediaCanPlayResponse
Parameters
type
String String

A string that describes the desired type as a MIME string.

Returns

A value of the enumeration that describes the likelihood that the current media engine can play the source.

CancelDirectManipulations CancelDirectManipulations CancelDirectManipulations CancelDirectManipulations

Cancels ongoing direct manipulation processing (system-defined panning/zooming) on any ScrollViewer parent that contains the current UIElement.

(Inherited from UIElement)

CapturePointer(Pointer) CapturePointer(Pointer) CapturePointer(Pointer) CapturePointer(Pointer)

Sets pointer capture to a UIElement. Once captured, only the element that has capture will fire pointer-related events.

(Inherited from UIElement)

ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

Clears the local value of a dependency property.

(Inherited from DependencyObject)

DeferTree(DependencyObject) DeferTree(DependencyObject) DeferTree(DependencyObject) DeferTree(DependencyObject)

Removes the specified element from the XAML visual tree in a way that it can be undeferred later.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

FindName(String) FindName(String) FindName(String) FindName(String)

Retrieves an object that has the specified identifier name.

(Inherited from FrameworkElement)

FindSubElementsForTouchTargeting(Point,Rect) FindSubElementsForTouchTargeting(Point,Rect) FindSubElementsForTouchTargeting(Point,Rect) FindSubElementsForTouchTargeting(Point,Rect)

Enables a UIElement subclass to expose child elements that assist with resolving touch targeting.

(Inherited from UIElement)

GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty)

Returns any base value established for a dependency property, which would apply in cases where an animation is not active.

(Inherited from DependencyObject)

GetAsCastingSource() GetAsCastingSource() GetAsCastingSource() GetAsCastingSource()

Returns the media element as a CastingSource.

public : CastingSource GetAsCastingSource()
CastingSource GetAsCastingSource() const;
public CastingSource GetAsCastingSource()
Public Function GetAsCastingSource() As CastingSource
Returns

The media element as a CastingSource.

Remarks

For more info about using MediaElement as a casting source, see Media casting.

See Also

GetAudioStreamLanguage(IReference) GetAudioStreamLanguage(IReference) GetAudioStreamLanguage(IReference) GetAudioStreamLanguage(IReference)

Returns the RFC 1766 language for the specified audio stream.

public : Platform::String GetAudioStreamLanguage(IReference<int> index)
winrt::hstring GetAudioStreamLanguage(IReference<int32_t> index) const;
public string GetAudioStreamLanguage(Nullable<Int32> index)
Public Function GetAudioStreamLanguage(index As Nullable<Int32>) As string
Parameters
index
Nullable<Int32> Nullable<Int32>

The index of the stream to get the language for.

If you are programming using C#or Microsoft Visual Basic, the type of this parameter is projected as int?(a nullable integer).

Returns
string string

The RFC 1766 language for the specified audio stream, expressed as a string (for example, "en-us").

GetBindingExpression(DependencyProperty) GetBindingExpression(DependencyProperty) GetBindingExpression(DependencyProperty) GetBindingExpression(DependencyProperty)

Returns the BindingExpression that represents the binding on the specified property.

(Inherited from FrameworkElement)

GetChildrenInTabFocusOrder GetChildrenInTabFocusOrder GetChildrenInTabFocusOrder GetChildrenInTabFocusOrder

Enables a UIElement subclass to expose child elements that take part in Tab focus.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

Returns the current effective value of a dependency property from a DependencyObject.

(Inherited from DependencyObject)

GoToElementStateCore(String,Boolean) GoToElementStateCore(String,Boolean) GoToElementStateCore(String,Boolean) GoToElementStateCore(String,Boolean)

When implemented in a derived class, enables per-state construction of a visual tree for a control template in code, rather than by loading XAML for all states at control startup.

(Inherited from FrameworkElement)

InvalidateArrange InvalidateArrange InvalidateArrange InvalidateArrange

Invalidates the arrange state (layout) for a UIElement. After the invalidation, the UIElement will have its layout updated, which will occur asynchronously.

(Inherited from UIElement)

InvalidateMeasure InvalidateMeasure InvalidateMeasure InvalidateMeasure

Invalidates the measurement state (layout) for a UIElement.

(Inherited from UIElement)

Measure(Size) Measure(Size) Measure(Size) Measure(Size)

Updates the DesiredSize of a UIElement. Typically, objects that implement custom layout for their layout children call this method from their own MeasureOverride implementations to form a recursive layout update.

(Inherited from UIElement)

MeasureOverride(Size) MeasureOverride(Size) MeasureOverride(Size) MeasureOverride(Size)

Provides the behavior for the "Measure" pass of the layout cycle. Classes can override this method to define their own "Measure" pass behavior.

(Inherited from FrameworkElement)

OnApplyTemplate OnApplyTemplate OnApplyTemplate OnApplyTemplate

Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.

(Inherited from FrameworkElement)

OnBringIntoViewRequested(BringIntoViewRequestedEventArgs) OnBringIntoViewRequested(BringIntoViewRequestedEventArgs) OnBringIntoViewRequested(BringIntoViewRequestedEventArgs) OnBringIntoViewRequested(BringIntoViewRequestedEventArgs)

Prerelease. Called before the BringIntoViewRequested event occurs.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

OnCreateAutomationPeer OnCreateAutomationPeer OnCreateAutomationPeer OnCreateAutomationPeer

When implemented in a derived class, returns class-specific AutomationPeer implementations for the Microsoft UI Automation infrastructure.

(Inherited from UIElement)

OnDisconnectVisualChildren OnDisconnectVisualChildren OnDisconnectVisualChildren OnDisconnectVisualChildren

Override this method to implement how layout and logic should behave when items are removed from a class-specific content or children property.

(Inherited from UIElement)

OnKeyboardAcceleratorInvoked(KeyboardAcceleratorInvokedEventArgs) OnKeyboardAcceleratorInvoked(KeyboardAcceleratorInvokedEventArgs) OnKeyboardAcceleratorInvoked(KeyboardAcceleratorInvokedEventArgs) OnKeyboardAcceleratorInvoked(KeyboardAcceleratorInvokedEventArgs)

Prerelease. Called when a keyboard shortcut (or accelerator) is processed in your app. Override this method to handle how your app responds when a keyboard accelerator is invoked.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs) OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs) OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs) OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs)

Called just before a keyboard shortcut (or accelerator) is processed in your app. Invoked whenever application code or internal processes call ProcessKeyboardAccelerators. Override this method to influence the default accelerator handling.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Pause() Pause() Pause() Pause()

Pauses media at the current position.

public : void Pause()
void Pause() const;
public void Pause()
Public Function Pause() As void

Play() Play() Play() Play()

Plays media from the current position.

public : void Play()
void Play() const;
public void Play()
Public Function Play() As void

ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

Returns the local value of a dependency property, if a local value is set.

(Inherited from DependencyObject)

RegisterAsScrollPort(UIElement) RegisterAsScrollPort(UIElement) RegisterAsScrollPort(UIElement) RegisterAsScrollPort(UIElement)

Prerelease. Registers an element as representing a scrollable viewport.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback)

Registers a notification function for listening to changes to a specific DependencyProperty on this DependencyObject instance.

(Inherited from DependencyObject)

ReleasePointerCapture(Pointer) ReleasePointerCapture(Pointer) ReleasePointerCapture(Pointer) ReleasePointerCapture(Pointer)

Releases pointer captures for capture of one specific pointer by this UIElement.

(Inherited from UIElement)

ReleasePointerCaptures ReleasePointerCaptures ReleasePointerCaptures ReleasePointerCaptures

Releases all pointer captures held by this element.

(Inherited from UIElement)

RemoveAllEffects() RemoveAllEffects() RemoveAllEffects() RemoveAllEffects()

Removes all effects for the next source set for this MediaElement.

public : void RemoveAllEffects()
void RemoveAllEffects() const;
public void RemoveAllEffects()
Public Function RemoveAllEffects() As void

RemoveHandler(RoutedEvent,Object) RemoveHandler(RoutedEvent,Object) RemoveHandler(RoutedEvent,Object) RemoveHandler(RoutedEvent,Object)

Removes the specified routed event handler from this UIElement. Typically the handler in question was added by AddHandler.

(Inherited from UIElement)

SetBinding(DependencyProperty,BindingBase) SetBinding(DependencyProperty,BindingBase) SetBinding(DependencyProperty,BindingBase) SetBinding(DependencyProperty,BindingBase)

Attaches a binding to a FrameworkElement, using the provided binding object

.

(Inherited from FrameworkElement)

SetMediaStreamSource(IMediaSource) SetMediaStreamSource(IMediaSource) SetMediaStreamSource(IMediaSource) SetMediaStreamSource(IMediaSource)

Sets the Source of the MediaElement to the specified MediaStreamSource.

public : void SetMediaStreamSource(IMediaSource source)
void SetMediaStreamSource(IMediaSource source) const;
public void SetMediaStreamSource(IMediaSource source)
Public Function SetMediaStreamSource(source As IMediaSource) As void
Parameters
source
IMediaSource IMediaSource

The media source.

SetPlaybackSource(IMediaPlaybackSource) SetPlaybackSource(IMediaPlaybackSource) SetPlaybackSource(IMediaPlaybackSource) SetPlaybackSource(IMediaPlaybackSource)

Sets the source of the MediaElement to the specified media playback source.

public : void SetPlaybackSource(IMediaPlaybackSource source)
void SetPlaybackSource(IMediaPlaybackSource source) const;
public void SetPlaybackSource(IMediaPlaybackSource source)
Public Function SetPlaybackSource(source As IMediaPlaybackSource) As void
Parameters
source
IMediaPlaybackSource IMediaPlaybackSource

The media playback source.

SetSource(IRandomAccessStream, String) SetSource(IRandomAccessStream, String) SetSource(IRandomAccessStream, String) SetSource(IRandomAccessStream, String)

Sets the Source property using the specified stream and MIME type.

public : void SetSource(IRandomAccessStream stream, Platform::String mimeType)
void SetSource(IRandomAccessStream stream, winrt::hstring mimeType) const;
public void SetSource(IRandomAccessStream stream, String mimeType)
Public Function SetSource(stream As IRandomAccessStream, mimeType As String) As void
Parameters
stream
IRandomAccessStream IRandomAccessStream

The stream that contains the media to load.

mimeType
String String

The MIME type of the media resource, expressed as the string form typically seen in HTTP headers and requests. The empty string "" can be passed in as the mimeType value if the MIME type is unknown.

Examples

Here is some code that creates MediaElement object and sets the media source using a FileOpenPicker control.

<MediaElement x:Name="mediaControl" Height="400" />
async private void SetLocalMedia()
{
    var openPicker = new Windows.Storage.Pickers.FileOpenPicker();

    openPicker.FileTypeFilter.Add(".wmv");
    openPicker.FileTypeFilter.Add(".mp4");
    openPicker.FileTypeFilter.Add(".wma");
    openPicker.FileTypeFilter.Add(".mp3");

    var file = await openPicker.PickSingleFileAsync();

    // mediaControl is a MediaElement defined in XAML
    if (null != file)
    {
        var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
        mediaControl.SetSource(stream, file.ContentType);
        mediaControl.Play();
    }
}

Remarks

You can use the FileOpenPicker control to get the file stream for a media file on the local system.

See Also

SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object)

Sets the local value of a dependency property on a DependencyObject.

(Inherited from DependencyObject)

StartBringIntoView StartBringIntoView StartBringIntoView StartBringIntoView

Initiates a request to the XAML framework to bring the element into view within any scrollable regions it is contained within.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

StartBringIntoView(BringIntoViewOptions) StartBringIntoView(BringIntoViewOptions) StartBringIntoView(BringIntoViewOptions) StartBringIntoView(BringIntoViewOptions)

Initiates a request to the XAML framework to bring the element into view using the specified options.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

StartDragAsync(PointerPoint) StartDragAsync(PointerPoint) StartDragAsync(PointerPoint) StartDragAsync(PointerPoint)

Initiates a drag-and-drop operation.

(Inherited from UIElement)

Stop() Stop() Stop() Stop()

Stops and resets media to be played from the beginning.

public : void Stop()
void Stop() const;
public void Stop()
Public Function Stop() As void

TransformToVisual(UIElement) TransformToVisual(UIElement) TransformToVisual(UIElement) TransformToVisual(UIElement)

Returns a transform object that can be used to transform coordinates from the UIElement to the specified object.

(Inherited from UIElement)

TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs) TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs) TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs) TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs)

Attempts to invoke a keyboard shortcut (or accelerator) by searching the entire visual tree of the UIElement for the shortcut.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

TryStartDirectManipulation(Pointer) TryStartDirectManipulation(Pointer) TryStartDirectManipulation(Pointer) TryStartDirectManipulation(Pointer)

Resumes direct manipulation processing (system-defined panning/zooming) on any ScrollViewer parent that contains the current UIElement.

(Inherited from UIElement)

UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64)

Cancels a change notification that was previously registered by calling RegisterPropertyChangedCallback.

(Inherited from DependencyObject)

UpdateLayout UpdateLayout UpdateLayout UpdateLayout

Ensures that all positions of child objects of a UIElement are properly updated for layout.

(Inherited from UIElement)

Events

AccessKeyDisplayDismissed AccessKeyDisplayDismissed AccessKeyDisplayDismissed AccessKeyDisplayDismissed

Occurs when the access key sequence is complete to notify controls that they should hide access key visuals.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AccessKeyDisplayRequested AccessKeyDisplayRequested AccessKeyDisplayRequested AccessKeyDisplayRequested

Occurs when the access key sequence is started to notify controls that they should show access key visuals.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AccessKeyInvoked AccessKeyInvoked AccessKeyInvoked AccessKeyInvoked

Occurs when a user completes an access key sequence to notify the element that the access key action should be invoked.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

ActualThemeChanged ActualThemeChanged ActualThemeChanged ActualThemeChanged

Occurs when the ActualTheme property value has changed.

(Inherited from FrameworkElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

BringIntoViewRequested BringIntoViewRequested BringIntoViewRequested BringIntoViewRequested

Prerelease. Occurs when StartBringIntoView is called on this element or one of its descendants.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

BufferingProgressChanged BufferingProgressChanged BufferingProgressChanged BufferingProgressChanged

Occurs when the BufferingProgress property changes.

public : event RoutedEventHandler BufferingProgressChanged<>
// Register
event_token BufferingProgressChanged(RoutedEventHandler<> const& handler) const;

// Revoke with event_token
void BufferingProgressChanged(event_token const& cookie) const;

// Revoke with event_revoker
BufferingProgressChanged_revoker BufferingProgressChanged(auto_revoker_t, RoutedEventHandler<> const& handler) const;
public event RoutedEventHandler BufferingProgressChanged<>
Public Event RoutedEventHandler BufferingProgressChanged( Of )
<MediaElement BufferingProgressChanged="eventhandler"/>

CharacterReceived CharacterReceived CharacterReceived CharacterReceived

Occurs when a single, composed character is received by the input queue.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

ContextCanceled ContextCanceled ContextCanceled ContextCanceled

Occurs when a context input gesture continues into a manipulation gesture, to notify the element that the context flyout should not be opened.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

ContextRequested ContextRequested ContextRequested ContextRequested

Occurs when the user has completed a context input gesture, such as a right-click.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

CurrentStateChanged CurrentStateChanged CurrentStateChanged CurrentStateChanged

Occurs when the value of the CurrentState property changes.

public : event RoutedEventHandler CurrentStateChanged<>
// Register
event_token CurrentStateChanged(RoutedEventHandler<> const& handler) const;

// Revoke with event_token
void CurrentStateChanged(event_token const& cookie) const;

// Revoke with event_revoker
CurrentStateChanged_revoker CurrentStateChanged(auto_revoker_t, RoutedEventHandler<> const& handler) const;
public event RoutedEventHandler CurrentStateChanged<>
Public Event RoutedEventHandler CurrentStateChanged( Of )
<MediaElement CurrentStateChanged="eventhandler"/>

DataContextChanged DataContextChanged DataContextChanged DataContextChanged

Occurs when the value of the FrameworkElement.DataContext property changes.

(Inherited from FrameworkElement)

DoubleTapped DoubleTapped DoubleTapped DoubleTapped

Occurs when an otherwise unhandled DoubleTap interaction occurs over the hit test area of this element.

(Inherited from UIElement)

DownloadProgressChanged DownloadProgressChanged DownloadProgressChanged DownloadProgressChanged

Occurs when the DownloadProgress property has changed.

public : event RoutedEventHandler DownloadProgressChanged<>
// Register
event_token DownloadProgressChanged(RoutedEventHandler<> const& handler) const;

// Revoke with event_token
void DownloadProgressChanged(event_token const& cookie) const;

// Revoke with event_revoker
DownloadProgressChanged_revoker DownloadProgressChanged(auto_revoker_t, RoutedEventHandler<> const& handler) const;
public event RoutedEventHandler DownloadProgressChanged<>
Public Event RoutedEventHandler DownloadProgressChanged( Of )
<MediaElement DownloadProgressChanged="eventhandler"/>

DragEnter DragEnter DragEnter DragEnter

Occurs when the input system reports an underlying drag event with this element as the target.

(Inherited from UIElement)

DragLeave DragLeave DragLeave DragLeave

Occurs when the input system reports an underlying drag event with this element as the origin.

(Inherited from UIElement)

DragOver DragOver DragOver DragOver

Occurs when the input system reports an underlying drag event with this element as the potential drop target.

(Inherited from UIElement)

DragStarting DragStarting DragStarting DragStarting

Occurs when a drag operation is initiated.

(Inherited from UIElement)

Drop Drop Drop Drop

Occurs when the input system reports an underlying drop event with this element as the drop target.

(Inherited from UIElement)

DropCompleted DropCompleted DropCompleted DropCompleted

Occurs when a drag-and-drop operation is ended.

(Inherited from UIElement)

GettingFocus GettingFocus GettingFocus GettingFocus

Occurs before a UIElement receives focus.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

GotFocus GotFocus GotFocus GotFocus

Occurs when a UIElement receives focus.

(Inherited from UIElement)

Holding Holding Holding Holding

Occurs when an otherwise unhandled Hold interaction occurs over the hit test area of this element.

(Inherited from UIElement)

KeyDown KeyDown KeyDown KeyDown

Occurs when a keyboard key is pressed while the UIElement has focus.

(Inherited from UIElement)

KeyUp KeyUp KeyUp KeyUp

Occurs when a keyboard key is released while the UIElement has focus.

(Inherited from UIElement)

LayoutUpdated LayoutUpdated LayoutUpdated LayoutUpdated

Occurs when the layout of the visual tree changes, due to layout-relevant properties changing value or some other action that refreshes the layout.

(Inherited from FrameworkElement)

Loaded Loaded Loaded Loaded

Occurs when a FrameworkElement has been constructed and added to the object tree, and is ready for interaction.

(Inherited from FrameworkElement)

Loading Loading Loading Loading

Occurs when a FrameworkElement begins to load.

(Inherited from FrameworkElement)

LosingFocus LosingFocus LosingFocus LosingFocus

Occurs before a UIElement loses focus.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

LostFocus LostFocus LostFocus LostFocus

Occurs when a UIElement loses focus.

(Inherited from UIElement)

ManipulationCompleted ManipulationCompleted ManipulationCompleted ManipulationCompleted

Occurs when a manipulation on the UIElement is complete.

(Inherited from UIElement)

ManipulationDelta ManipulationDelta ManipulationDelta ManipulationDelta

Occurs when the input device changes position during a manipulation.

(Inherited from UIElement)

ManipulationInertiaStarting ManipulationInertiaStarting ManipulationInertiaStarting ManipulationInertiaStarting

Occurs when the input device loses contact with the UIElement object during a manipulation and inertia begins.

(Inherited from UIElement)

ManipulationStarted ManipulationStarted ManipulationStarted ManipulationStarted

Occurs when an input device begins a manipulation on the UIElement.

(Inherited from UIElement)

ManipulationStarting ManipulationStarting ManipulationStarting ManipulationStarting

Occurs when the manipulation processor is first created.

(Inherited from UIElement)

MarkerReached MarkerReached MarkerReached MarkerReached

Occurs when a timeline marker is encountered during media playback.

public : event TimelineMarkerRoutedEventHandler MarkerReached<>
// Register
event_token MarkerReached(TimelineMarkerRoutedEventHandler<> const& handler) const;

// Revoke with event_token
void MarkerReached(event_token const& cookie) const;

// Revoke with event_revoker
MarkerReached_revoker MarkerReached(auto_revoker_t, TimelineMarkerRoutedEventHandler<> const& handler) const;
public event TimelineMarkerRoutedEventHandler MarkerReached<>
Public Event TimelineMarkerRoutedEventHandler MarkerReached( Of )
<MediaElement MarkerReached="eventhandler"/>

Examples

The following example creates a MediaElement object and responds to its MarkerReached event. Each time a timeline marker is reached, the example displays the timeline marker's Time, Type, and Text values.

<MediaElement Name="Media" Source="video.mp4" MarkerReached="Media_MarkerReached" />
<TextBlock Name="txOutput" />
private void Media_MarkerReached(object sender, TimelineMarkerRoutedEventArgs e)
{
    txOutput.Text =
        string.Format("{0},{1},{2}", e.Marker.Time, e.Marker.Text, e.Marker.Type);
}

MediaEnded MediaEnded MediaEnded MediaEnded

Occurs when the MediaElement finishes playing audio or video.

public : event RoutedEventHandler MediaEnded<>
// Register
event_token MediaEnded(RoutedEventHandler<> const& handler) const;

// Revoke with event_token
void MediaEnded(event_token const& cookie) const;

// Revoke with event_revoker
MediaEnded_revoker MediaEnded(auto_revoker_t, RoutedEventHandler<> const& handler) const;
public event RoutedEventHandler MediaEnded<>
Public Event RoutedEventHandler MediaEnded( Of )
<MediaElement MediaEnded="eventhandler" ../>

MediaFailed MediaFailed MediaFailed MediaFailed

Occurs when there is an error associated with the media Source.

public : event ExceptionRoutedEventHandler MediaFailed<>
// Register
event_token MediaFailed(ExceptionRoutedEventHandler<> const& handler) const;

// Revoke with event_token
void MediaFailed(event_token const& cookie) const;

// Revoke with event_revoker
MediaFailed_revoker MediaFailed(auto_revoker_t, ExceptionRoutedEventHandler<> const& handler) const;
public event ExceptionRoutedEventHandler MediaFailed<>
Public Event ExceptionRoutedEventHandler MediaFailed( Of )
<MediaElement MediaFailed="eventhandler" .../>

Examples

The following code creates a MediaFailed event handler that calls a helper function to retrieve the HRESULT from the event arguments.

private void videoMediaElement_MediaFailed(object sender, ExceptionRoutedEventArgs e)
{
    // get HRESULT from event args 
    string hr = GetHresultFromErrorMessage(e);

    // Handle media failed event appropriately 
}

private string GetHresultFromErrorMessage(ExceptionRoutedEventArgs e)
{
    String hr = String.Empty;
    String token = "HRESULT - ";
    const int hrLength = 10;     // eg "0xFFFFFFFF"

    int tokenPos = e.ErrorMessage.IndexOf(token, StringComparison.Ordinal);
    if (tokenPos != -1)
    {
        hr = e.ErrorMessage.Substring(tokenPos + token.Length, hrLength);
    }

    return hr;
}

Remarks

It is a best practice to always handle the MediaFailed event and take appropriate action.

MediaOpened MediaOpened MediaOpened MediaOpened

Occurs when the media stream has been validated and opened, and the file headers have been read.

public : event RoutedEventHandler MediaOpened<>
// Register
event_token MediaOpened(RoutedEventHandler<> const& handler) const;

// Revoke with event_token
void MediaOpened(event_token const& cookie) const;

// Revoke with event_revoker
MediaOpened_revoker MediaOpened(auto_revoker_t, RoutedEventHandler<> const& handler) const;
public event RoutedEventHandler MediaOpened<>
Public Event RoutedEventHandler MediaOpened( Of )
<MediaElement MediaOpened="eventhandler" .../>

Examples

The following code shows how to determine if a media stream is a live stream.

private void media_MediaOpened(object sender, RoutedEventArgs e)
{
    bool isLive = IsLiveStream(sender as MediaElement);
}

private bool IsLiveStream(MediaElement media)
{
    bool isLive = false;

    if (media.NaturalDuration.TimeSpan.Ticks == Int64.MaxValue)
    {
       isLive = true;
    }

    return isLive;
}

Remarks

Live media streams report a NaturalDuration of Int64.MaxValue.

Any calls to Play, Pause, and Stop methods that occur before the MediaOpened event is raised are ignored.

NoFocusCandidateFound NoFocusCandidateFound NoFocusCandidateFound NoFocusCandidateFound

Occurs when a user attempts to move focus (via tab or directional arrows), but focus doesn't move because no focus candidate is found in the direction of movement.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

PartialMediaFailureDetected PartialMediaFailureDetected PartialMediaFailureDetected PartialMediaFailureDetected

Occurs when one or more streams fails to decode in content containing multiple streams.

public : event TypedEventHandler PartialMediaFailureDetected<MediaElement, PartialMediaFailureDetectedEventArgs>
// Register
event_token PartialMediaFailureDetected(TypedEventHandler<MediaElement, PartialMediaFailureDetectedEventArgs> const& handler) const;

// Revoke with event_token
void PartialMediaFailureDetected(event_token const& cookie) const;

// Revoke with event_revoker
PartialMediaFailureDetected_revoker PartialMediaFailureDetected(auto_revoker_t, TypedEventHandler<MediaElement, PartialMediaFailureDetectedEventArgs> const& handler) const;
public event TypedEventHandler PartialMediaFailureDetected<MediaElement, PartialMediaFailureDetectedEventArgs>
Public Event TypedEventHandler PartialMediaFailureDetected( Of ( Of MediaElement ), ( Of PartialMediaFailureDetectedEventArgs ))

Remarks

If at least one stream in the content is successfully decoded, the decoded media is played and this event is raised. If the stream that fails to decode is the only stream contained in the content, playback fails and the MediaFailed event is raised.

PointerCanceled PointerCanceled PointerCanceled PointerCanceled

Occurs when a pointer that made contact abnormally loses contact.

(Inherited from UIElement)

PointerCaptureLost PointerCaptureLost PointerCaptureLost PointerCaptureLost

Occurs when pointer capture previously held by this element moves to another element or elsewhere.

(Inherited from UIElement)

PointerEntered PointerEntered PointerEntered PointerEntered

Occurs when a pointer enters the hit test area of this element.

(Inherited from UIElement)

PointerExited PointerExited PointerExited PointerExited

Occurs when a pointer leaves the hit test area of this element.

(Inherited from UIElement)

PointerMoved PointerMoved PointerMoved PointerMoved

Occurs when a pointer moves while the pointer remains within the hit test area of this element.

(Inherited from UIElement)

PointerPressed PointerPressed PointerPressed PointerPressed

Occurs when the pointer device initiates a Press action within this element.

(Inherited from UIElement)

PointerReleased PointerReleased PointerReleased PointerReleased

Occurs when the pointer device that previously initiated a Press action is released, while within this element. Note that the end of a Press action is not guaranteed to fire a PointerReleased event; other events may fire instead. For more info, see Remarks.

(Inherited from UIElement)

PointerWheelChanged PointerWheelChanged PointerWheelChanged PointerWheelChanged

Occurs when the delta value of a pointer wheel changes.

(Inherited from UIElement)

PreviewKeyDown PreviewKeyDown PreviewKeyDown PreviewKeyDown

Occurs when a keyboard key is pressed while the UIElement has focus.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

PreviewKeyUp PreviewKeyUp PreviewKeyUp PreviewKeyUp

Occurs when a keyboard key is released while the UIElement has focus.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

ProcessKeyboardAccelerators ProcessKeyboardAccelerators ProcessKeyboardAccelerators ProcessKeyboardAccelerators

Occurs when a keyboard shortcut (or accelerator) is pressed.

(Inherited from UIElement)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

RateChanged RateChanged RateChanged RateChanged

Occurs when PlaybackRate or DefaultPlaybackRate value changes.

public : event RateChangedRoutedEventHandler RateChanged<>
// Register
event_token RateChanged(RateChangedRoutedEventHandler<> const& handler) const;

// Revoke with event_token
void RateChanged(event_token const& cookie) const;

// Revoke with event_revoker
RateChanged_revoker RateChanged(auto_revoker_t, RateChangedRoutedEventHandler<> const& handler) const;
public event RateChangedRoutedEventHandler RateChanged<>
Public Event RateChangedRoutedEventHandler RateChanged( Of )
<MediaElement RateChanged="eventhandler"/>

RightTapped RightTapped RightTapped RightTapped

Occurs when a right-tap input stimulus happens while the pointer is over the element.

(Inherited from UIElement)

SeekCompleted SeekCompleted SeekCompleted SeekCompleted

Occurs when the seek point of a requested seek operation is ready for playback.

public : event RoutedEventHandler SeekCompleted<>
// Register
event_token SeekCompleted(RoutedEventHandler<> const& handler) const;

// Revoke with event_token
void SeekCompleted(event_token const& cookie) const;

// Revoke with event_revoker
SeekCompleted_revoker SeekCompleted(auto_revoker_t, RoutedEventHandler<> const& handler) const;
public event RoutedEventHandler SeekCompleted<>
Public Event RoutedEventHandler SeekCompleted( Of )
<MediaElement SeekCompleted="eventhandler"/>

SizeChanged SizeChanged SizeChanged SizeChanged

Occurs when either the ActualHeight or the ActualWidth property changes value on a FrameworkElement.

(Inherited from FrameworkElement)

Tapped Tapped Tapped Tapped

Occurs when an otherwise unhandled Tap interaction occurs over the hit test area of this element.

(Inherited from UIElement)

Unloaded Unloaded Unloaded Unloaded

Occurs when this object is no longer connected to the main object tree.

(Inherited from FrameworkElement)

VolumeChanged VolumeChanged VolumeChanged VolumeChanged

Occurs when the value of the Volume property changes.

public : event RoutedEventHandler VolumeChanged<>
// Register
event_token VolumeChanged(RoutedEventHandler<> const& handler) const;

// Revoke with event_token
void VolumeChanged(event_token const& cookie) const;

// Revoke with event_revoker
VolumeChanged_revoker VolumeChanged(auto_revoker_t, RoutedEventHandler<> const& handler) const;
public event RoutedEventHandler VolumeChanged<>
Public Event RoutedEventHandler VolumeChanged( Of )
<MediaElement VolumeChanged="eventhandler" />

See Also