Skip to content

Latest commit

 

History

History
90 lines (65 loc) · 7.51 KB

MediaPlayerElement.md

File metadata and controls

90 lines (65 loc) · 7.51 KB
title author description keywords
MediaPlayerElement control for Windows Forms and WPF
granitestatehacker
This control is a wrapper to enable use of the UWP MediaPlayerElement control in Windows Forms or WPF.
windows 10, uwp, windows community toolkit, uwp community toolkit, uwp toolkit, MediaPlayerElement, Windows Forms, WPF

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).

MediaPlayterElement example

Note

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.

[!div class="nextstepaction"] Try it in the sample app

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.

Requirements

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.

Syntax

<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" />

Properties

The following properties wrap corresponding properties of the wrapped UWP Windows.UI.Xaml.Controls.MediaPlayerElement object. See the links in this table for more information about each property.

Property Type Description
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.

Methods

Methods Return Type Description
SetMediaPlayer(MediaPlayer) void Wraps the SetMediaPlayer method of the wrapped UWP MediaPlayerElement control.

Requirements

Device family .NET 4.6.2, Windows 10 (introduced v10.0.17709.0)
Namespace Windows Forms: Microsoft.Toolkit.Forms.UI.Controls
WPF: Microsoft.Toolkit.Wpf.UI.Controls
NuGet package Windows Forms: Microsoft.Toolkit.Forms.UI.Controls
WPF: Microsoft.Toolkit.Wpf.UI.Controls

API

Related topics