Occurs when there is an error associated with the media Source.
Syntax
<MediaElement MediaFailed="eventhandler" .../>
Event information
| Delegate | ExceptionRoutedEventHandler |
|---|
Remarks
It is a best practice to always handle the MediaFailed event and take appropriate action.
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; }
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 3/12/2013