private void MediaElementOnMediaFailed(object sender, ExceptionRoutedEventArgs args)
{
if (_textBlockError == null) {
_textBlockError = new TextBlock {
Foreground = Brushes.White,
FontSize = 14,
Margin = new Thickness(2),
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top,
TextWrapping = TextWrapping.WrapWithOverflow,
Effect = new DropShadowEffect {
ShadowDepth = 0,
Color = Colors.Black,
BlurRadius = 8
}
};
((Grid) Content).Children.Add(_textBlockError);
}
_textBlockError.Text = $"Playing {_mediaElement.Source} failed.\n{args.ErrorException.Message}";
}