I can't reproduce the error with you code , below is my simple demo to display the 4k video and it runs well.
The xaml code is:
<xamlhost:WindowsXamlHost x:Name="myMediaPlayer" InitialTypeName="Windows.UI.Xaml.Controls.MediaPlayerElement" Loaded="myMediaPlayer_Loaded"/>
The code for myMediaPlayer_Loaded:
private async void myMediaPlayer_Loaded(object sender, RoutedEventArgs e)
{
WindowsXamlHost windowsXamlHost = (WindowsXamlHost)sender;
Windows.UI.Xaml.Controls.MediaPlayerElement mediaPlayerElement = (Windows.UI.Xaml.Controls.MediaPlayerElement)windowsXamlHost.Child;
StorageFile file = await StorageFile.GetFileFromPathAsync(@"C:\Users\daisyt\Videos\4k.mp4");
mediaPlayerElement.Source = MediaSource.CreateFromStorageFile(file);
mediaPlayerElement.AreTransportControlsEnabled = true;
mediaPlayerElement.AutoPlay = true;
}
Could you use my code to create your a MediaPlayerElement to check if it can play your 4k/uhd videos?
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.