Class MediaElement
Represents an object that contains audio, video, or both.
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
public sealed class MediaElement : FrameworkElement, IFrameworkElement, IUIElement, IDependencyObject
Fields
| Improve this Doc View SourceAutoPlayProperty
Identifies the AutoPlay dependency property.
Declaration
public static readonly DependencyProperty AutoPlayProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
BufferingTimeProperty
Identifies the BufferingTime dependency property.
Declaration
[NotImplemented]
public static readonly DependencyProperty BufferingTimeProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
CurrentStateProperty
Identifies the CurrentState dependency property.
Declaration
[NotImplemented]
public static readonly DependencyProperty CurrentStateProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
DownloadProgressOffsetProperty
Identifies the DownloadProgressOffset dependency property.
Declaration
[NotImplemented]
public static readonly DependencyProperty DownloadProgressOffsetProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
DownloadProgressProperty
Identifies the DownloadProgress dependency property.
Declaration
[NotImplemented]
public static readonly DependencyProperty DownloadProgressProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
IsAudioOnlyProperty
Identifies the IsAudioOnly dependency property.
Declaration
public static readonly DependencyProperty IsAudioOnlyProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
IsLoopingProperty
Identifies the IsLooping dependency property.
Declaration
public static readonly DependencyProperty IsLoopingProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
IsMutedProperty
Identifies the IsMuted dependency property.
Declaration
public static readonly DependencyProperty IsMutedProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
NaturalDurationProperty
Identifies the NaturalDuration dependency property.
Declaration
[NotImplemented]
public static readonly DependencyProperty NaturalDurationProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
PositionProperty
Identifies the Position dependency property.
Declaration
[NotImplemented]
public static readonly DependencyProperty PositionProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
ShowControlsProperty
Identifies the ShowControls dependency property.
Declaration
public static readonly DependencyProperty ShowControlsProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
SourceProperty
Identifies the Source dependency property.
Declaration
public static readonly DependencyProperty SourceProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
StretchProperty
Identifies the Stretch dependency property.
Declaration
[NotImplemented]
public static readonly DependencyProperty StretchProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
VolumeProperty
Identifies the Volume dependency property.
Declaration
public static readonly DependencyProperty VolumeProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
Properties
| Improve this Doc View SourceAutoPlay
Gets or sets a value that indicates whether media will begin playback automatically when the Source property is set.
Declaration
public bool AutoPlay { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
BufferingTime
The amount of time to buffer. The default value is a System.TimeSpan with value of 5 seconds (0:0:05).
Declaration
[NotImplemented]
public TimeSpan BufferingTime { get; set; }
Property Value
| Type | Description |
|---|---|
| System.TimeSpan |
CurrentState
Gets the status of the MediaElement.
Declaration
[NotImplemented]
public MediaElementState CurrentState { get; }
Property Value
| Type | Description |
|---|---|
| MediaElementState |
DownloadProgress
Gets a percentage value indicating the amount of download completed for content located on a remote server.
Declaration
[NotImplemented]
public double DownloadProgress { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
DownloadProgressOffset
Gets the offset of the download progress.
Declaration
[NotImplemented]
public double DownloadProgressOffset { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
IsAudioOnly
Gets a value that reports whether the current source media is an audio-only media file.
Declaration
public bool IsAudioOnly { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsLooping
Gets or sets a value that describes whether the media source currently loaded in the media engine should automatically set the position to the media start after reaching its end.
Declaration
public bool IsLooping { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsMuted
Gets or sets a value indicating whether the audio is muted.
Declaration
public bool IsMuted { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Markers
The collection of timeline markers (represented as TimelineMarker objects) associated with the currently loaded media file.
Declaration
[NotImplemented]
public TimelineMarkerCollection Markers { get; }
Property Value
| Type | Description |
|---|---|
| TimelineMarkerCollection |
NaturalDuration
Gets the duration of the media file currently opened.
Declaration
[NotImplemented]
public Duration NaturalDuration { get; }
Property Value
| Type | Description |
|---|---|
| Duration |
Position
Gets or sets the current position of progress through the media's playback time.
Declaration
[NotImplemented]
public TimeSpan Position { get; set; }
Property Value
| Type | Description |
|---|---|
| System.TimeSpan |
ShowControls
Declaration
public bool ShowControls { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Source
Gets or sets a media source on the MediaElement.
Declaration
public Uri Source { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Uri |
Stretch
Gets or sets a Stretch value that describes how a MediaElement fills the destination rectangle.
Declaration
[NotImplemented]
public Stretch Stretch { get; set; }
Property Value
| Type | Description |
|---|---|
| Stretch |
Volume
Gets or sets the media's volume.
Declaration
public double Volume { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Methods
| Improve this Doc View SourceCanPlayType(String)
Returns an enumeration value that describes the likelihood that the current MediaElement and its client configuration can play that media source.
Declaration
public MediaCanPlayResponse CanPlayType(string type)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | type | A string that describes the desired type as a string. |
Returns
| Type | Description |
|---|---|
| MediaCanPlayResponse | A value of the enumeration that describes the likelihood that the current media engine can play the source. |
CreateDomElement(Object, out Object)
Declaration
public override object CreateDomElement(object parentRef, out object domElementWhereToPlaceChildren)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | parentRef | |
| System.Object | domElementWhereToPlaceChildren |
Returns
| Type | Description |
|---|---|
| System.Object |
Overrides
| Improve this Doc View SourceOnCreateAutomationPeer()
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
| Type | Description |
|---|---|
| AutomationPeer |
Overrides
| Improve this Doc View SourcePause()
Pauses media at the current position.
Declaration
public void Pause()
Play()
Plays media from the current position.
Declaration
public void Play()
SetSource(Stream)
Sets the Source property using the supplied stream.
Declaration
[NotImplemented]
public void SetSource(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | stream | A stream that contains a natively supported media source. |
Stop()
Stops and resets media to be played from the beginning.
Declaration
[NotImplemented]
public void Stop()
Events
| Improve this Doc View SourceCurrentStateChanged
Occurs when the value of the CurrentState property changes.
Declaration
[NotImplemented]
public event RoutedEventHandler CurrentStateChanged
Event Type
| Type | Description |
|---|---|
| RoutedEventHandler |
DownloadProgressChanged
Occurs when the DownloadProgress property has changed.
Declaration
[NotImplemented]
public event RoutedEventHandler DownloadProgressChanged
Event Type
| Type | Description |
|---|---|
| RoutedEventHandler |
MediaEnded
Occurs when the MediaElement is no longer playing audio or video.
Declaration
[NotImplemented]
public event RoutedEventHandler MediaEnded
Event Type
| Type | Description |
|---|---|
| RoutedEventHandler |
MediaFailed
Declaration
[NotImplemented]
public event EventHandler<ExceptionRoutedEventArgs> MediaFailed
Event Type
| Type | Description |
|---|---|
| System.EventHandler<ExceptionRoutedEventArgs> |
MediaOpened
Declaration
[NotImplemented]
public event RoutedEventHandler MediaOpened
Event Type
| Type | Description |
|---|---|
| RoutedEventHandler |