Share via


MediaFailed Event

Occurs when there is a media related error.

XAML
<object MediaFailed="eventhandlerFunction" .../>
Scripting
[token = ]object.AddEventListener("MediaFailed", eventhandlerFunction)

AddEventListener Parameters

token

integer

A token that is returned from the function, which you can optionally retain as a variable. If you intend to call RemoveEventListener to remove the handler, you will need this token.

eventhandlerFunction

object

The name of your event handler function as it is defined in script. When used as an AddEventListener parameter, quotes around the function name are not required. See Remarks.

Event Handler Parameters

sender

object

Identifies the object that invoked the event.

eventArgs

object

This parameter is always set to null.

Remarks

Conditions in which this event can occur include:

  • File not found.
  • Invalid file format - unrecognized or unsupported media format.
  • Unknown media error during playback.

Setting a cross-domain URI for Source will either succeed, or will not return a valid status for any failure. An error is thrown on the SetValue method call for setting "Source" in this case.

You can also add handlers in script using a quoted string for the event handler name:

object.AddEventListener("MediaFailed", "eventhandlerFunction")

This syntax also returns a token; however, the token is not an absolute requirement for removing the handler, in cases where the handler was added by using a quoted string. For details, see RemoveEventListener.

For more information on Silverlight errors and error handling, see Silverlight Error Handling. For a list of error messages associated with this event, see Error Messages.

Applies To

MediaElement

See Also

Error Handling
Error Messages
Silverlight Events
Media Overview