MediaOpened Event

Occurs when the media stream has been validated, opened, and the file headers have been read.

<object MediaOpened="eventhandlerFunction" .../>
[token = ]object.AddEventListener("MediaOpened", eventhandlerFunction)

AddEventListener Parameters



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.



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



Identifies the object that invoked the event.



This parameter is always set to null.


A MediaElement generally possesses two types of properties: properties that are settable and that declare appearance or behavior of the MediaElement , and read-only properties that report on characteristics of the current Source file that is loaded by the MediaElement. Properties in this second category will not contain valid values until the MediaElement raises the MediaOpened event. The following is a list of MediaElement properties that will not be valid until after MediaOpened is raised by that element.

Also, Position will be null prior to MediaOpened, but Position is slightly different because it is settable. You should not attempt to set Position until MediaOpened is raised. You also should not set an initial Position value in XAML.

If the AutoPlay property is set to false, the media will be paused when the MediaOpened event occurs.

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

object.AddEventListener("MediaOpened", "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.

Applies To


See Also

Silverlight Events
Media Overview