MediaPlayerElement control for Windows Forms and WPF
The MediaPlayerElement control embeds a view that streams and renders media content such as video in your Windows Forms or WPF desktop application. This is one of several wrapped Universal Windows Platform controls that are available for Windows Forms and WPF applications as part of a feature called XAML Islands. For more information, see UWP controls in desktop applications (XAML Islands).
This control is currently available as a developer preview for Windows 10, version 1903, and later. Although we encourage you to try out this control in your own prototype code now, we do not recommend that you use it in production code at this time. For more information, see the XAML Islands feature roadmap. If you have feedback about this control, create a new issue in the Microsoft.Toolkit.Win32 repo and leave your comments there. If you prefer to submit your feedback privately, you can send it to XamlIslandsFeedback@microsoft.com.
About MediaPlayerElement control
This control wraps an instance of the UWP Windows.UI.Xaml.Controls.MediaPlayerElement control. The WPF version of this control is located in the Microsoft.Toolkit.Wpf.UI.Controls namespace. The Windows Forms version is located in the Microsoft.Toolkit.Forms.UI.Controls namespace. You can find additional related types (such as enums and event args classes) in the Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT namespace.
Before you can use this control, you must follow these instructions to configure your project to support XAML Islands.
Known issues and limitations
- This controls does not currently support full screen video.
- The Source property is exposed as a string, which is interpreted as a URL and bound to the Source property of the wrapped UWP control as a UWP-implemented IMediaPlaybackSource.
- See also our list of known issues for WPF and Windows Forms controls in the Windows Community Toolkit repo.
<Window x:Class="TestSample.MainWindow" ... xmlns:controls="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls" ...> <controls:MediaPlayerElement x:Name="mediaPlayerElement" Source="https://mediaplatstorage1.blob.core.windows.net/windows-universal-samples-media/elephantsdream-clip-h264_sd-aac_eng-aac_spa-aac_eng_commentary-srt_eng-srt_por-srt_swe.mkv" AutoPlay="True" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AreTransportControlsEnabled="True" />
|AreTransportControlsEnabled||bool||Wraps the AreTransportControlsEnabled property.|
|AreTransportControlsEnabledProperty||DependencyProperty||Dependency property for the AreTransportControlsEnabled property.|
|AutoPlay||bool||Wraps the AutoPlay property.|
|AutoPlayProperty||DependencyProperty||Dependency property for the ActiAutoPlayveTool property.|
|IsFullWindow||bool||Wraps the IsFullWindow property.|
|IsFullWindowProperty||DependencyProperty||Dependency property for the IsFullWindow property.|
|MediaPlayer||MediaPlayer||Wraps the MediaPlayer property.|
|MediaPlayerProperty||DependencyProperty||Dependency property for the MediaPlayer property.|
|PosterSource||ImageSource||Wraps the PosterSource property.|
|PosterSourceProperty||DependencyProperty||Dependency property for the PosterSource property.|
|Source||string||Wraps the Source property. The Source property of this wrapped control is exposed as a string, which is interpreted as a URL and bound to the Source property of the wrapped UWP control as a UWP-implemented IMediaPlaybackSource.|
|SourceProperty||DependencyProperty||Dependency property for the Source property.|
|Stretch||Stretch||Wraps the Stretch property.|
|StretchProperty||DependencyProperty||Dependency property for the Stretch property.|
|TransportControls||MediaTransportControls||Wraps the TransportControls property.|
|SetMediaPlayer(MediaPlayer)||void||Wraps the SetMediaPlayer method of the wrapped UWP MediaPlayerElement control.|
|Device family||.NET 4.6.2, Windows 10 (introduced v10.0.17709.0)|
|Namespace||Windows Forms: Microsoft.Toolkit.Forms.UI.Controls
|NuGet package||Windows Forms: Microsoft.Toolkit.Forms.UI.Controls
API source code