Bagikan melalui


MediaElement.MediaOpened Event

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Event MediaOpened As RoutedEventHandler
public event RoutedEventHandler MediaOpened
<MediaElement MediaOpened="eventhandler" .../>

Remarks

A MediaElement object generally has two types of properties:

  • Properties that are settable and that declare the appearance or behavior of the MediaElement.

  • Read-only properties that report on the 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.

In addition, the Position property will be null before the MediaOpened event. However, Position is different from the other properties in the second group 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.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.