Unosquare
    Show / Hide Table of Contents

    Class MediaElement

    Represents a control that contains audio and/or video. In contrast with System.Windows.Controls.MediaElement, this version uses the FFmpeg library to perform reading and decoding of media streams.

    Inheritance
    Object
    MediaElement
    Implements
    IUriContext
    IDisposable
    Namespace: Unosquare.FFME
    Syntax
    public sealed class MediaElement : UserControl, IUriContext, IDisposable

    Constructors

    MediaElement()

    Initializes a new instance of the MediaElement class.

    Declaration
    public MediaElement()

    Fields

    BalanceProperty

    The DependencyProperty for the MediaElement.Balance property.

    Declaration
    public static readonly DependencyProperty BalanceProperty
    Field Value
    Type Description
    DependencyProperty

    ClosedCaptionsChannelProperty

    The DependencyProperty for the MediaElement.ClosedCaptionsChannel property.

    Declaration
    public static readonly DependencyProperty ClosedCaptionsChannelProperty
    Field Value
    Type Description
    DependencyProperty

    IgnorePixelAspectRatioProperty

    DependencyProperty for StretchDirection property.

    Declaration
    public static readonly DependencyProperty IgnorePixelAspectRatioProperty
    Field Value
    Type Description
    DependencyProperty

    IsDesignPreviewEnabledProperty

    The DependencyProperty for the MediaElement.IsDesignPreviewEnabled property.

    Declaration
    public static readonly DependencyProperty IsDesignPreviewEnabledProperty
    Field Value
    Type Description
    DependencyProperty

    IsMutedProperty

    The DependencyProperty for the MediaElement.IsMuted property.

    Declaration
    public static readonly DependencyProperty IsMutedProperty
    Field Value
    Type Description
    DependencyProperty

    LoadedBehaviorProperty

    The DependencyProperty for the MediaElement.LoadedBehavior property.

    Declaration
    public static readonly DependencyProperty LoadedBehaviorProperty
    Field Value
    Type Description
    DependencyProperty

    LoopingBehaviorProperty

    The DependencyProperty for the MediaElement.LoopingBehavior property.

    Declaration
    public static readonly DependencyProperty LoopingBehaviorProperty
    Field Value
    Type Description
    DependencyProperty

    PositionProperty

    The DependencyProperty for the MediaElement.Position property.

    Declaration
    public static readonly DependencyProperty PositionProperty
    Field Value
    Type Description
    DependencyProperty

    ScrubbingEnabledProperty

    The DependencyProperty for the MediaElement.ScrubbingEnabled property.

    Declaration
    public static readonly DependencyProperty ScrubbingEnabledProperty
    Field Value
    Type Description
    DependencyProperty

    SpeedRatioProperty

    The DependencyProperty for the MediaElement.SpeedRatio property.

    Declaration
    public static readonly DependencyProperty SpeedRatioProperty
    Field Value
    Type Description
    DependencyProperty

    StretchDirectionProperty

    DependencyProperty for StretchDirection property.

    Declaration
    public static readonly DependencyProperty StretchDirectionProperty
    Field Value
    Type Description
    DependencyProperty

    StretchProperty

    DependencyProperty for Stretch property.

    Declaration
    public static readonly DependencyProperty StretchProperty
    Field Value
    Type Description
    DependencyProperty

    UnloadedBehaviorProperty

    The DependencyProperty for the MediaElement.UnloadedBehavior property.

    Declaration
    public static readonly DependencyProperty UnloadedBehaviorProperty
    Field Value
    Type Description
    DependencyProperty

    VerticalSyncEnabledProperty

    The DependencyProperty for the MediaElement.VerticalSyncEnabled property.

    Declaration
    public static readonly DependencyProperty VerticalSyncEnabledProperty
    Field Value
    Type Description
    DependencyProperty

    VolumeProperty

    The DependencyProperty for the MediaElement.Volume property.

    Declaration
    public static readonly DependencyProperty VolumeProperty
    Field Value
    Type Description
    DependencyProperty

    Properties

    Balance

    Gets/Sets the Balance property on the MediaElement.

    Declaration
    public double Balance { get; set; }
    Property Value
    Type Description
    Double

    ClosedCaptionsChannel

    Gets/Sets the ClosedCaptionsChannel property on the MediaElement. Note: Valid values are from 0 to 1.

    Declaration
    public CaptionsChannel ClosedCaptionsChannel { get; set; }
    Property Value
    Type Description
    CaptionsChannel

    IgnorePixelAspectRatio

    Gets/Sets the stretch direction of the ViewBox, which determines the restrictions on scaling that are applied to the content inside the ViewBox. For instance, this property can be used to prevent the content from being smaller than its native size or larger than its native size.

    Declaration
    public bool IgnorePixelAspectRatio { get; set; }
    Property Value
    Type Description
    Boolean

    IsDesignPreviewEnabled

    Gets or sets a value that indicates whether the MediaElement will display a preview image in design time. This is a dependency property.

    Declaration
    public bool IsDesignPreviewEnabled { get; set; }
    Property Value
    Type Description
    Boolean

    IsMuted

    Gets/Sets the IsMuted property on the MediaElement.

    Declaration
    public bool IsMuted { get; set; }
    Property Value
    Type Description
    Boolean

    LoadedBehavior

    Specifies the action that the media element should execute when it is loaded. The default behavior is that it is under manual control (i.e. the caller should call methods such as Play in order to play the media). If a source is set, then the default behavior changes to to be playing the media. If a source is set and a loaded behavior is also set, then the loaded behavior takes control.

    Declaration
    public MediaPlaybackState LoadedBehavior { get; set; }
    Property Value
    Type Description
    MediaPlaybackState

    LoopingBehavior

    Specifies how the media should behave when it has ended. The default behavior is to Pause the media.

    Declaration
    public MediaPlaybackState LoopingBehavior { get; set; }
    Property Value
    Type Description
    MediaPlaybackState

    Position

    Gets/Sets the Position property on the MediaElement.

    Declaration
    public TimeSpan Position { get; set; }
    Property Value
    Type Description
    TimeSpan

    RendererOptions

    Provides access to various internal media renderer options. The default options are optimal to work for most media streams. This is an advanced feature and it is not recommended to change these options without careful consideration.

    Declaration
    public RendererOptions RendererOptions { get; }
    Property Value
    Type Description
    RendererOptions

    ScrubbingEnabled

    Gets or sets a value that indicates whether the MediaElement will update frames for seek operations while paused. This is a dependency property.

    Declaration
    public bool ScrubbingEnabled { get; set; }
    Property Value
    Type Description
    Boolean

    SpeedRatio

    Gets/Sets the SpeedRatio property on the MediaElement.

    Declaration
    public double SpeedRatio { get; set; }
    Property Value
    Type Description
    Double

    Stretch

    Gets/Sets the Stretch on this MediaElement. The Stretch property determines how large the MediaElement will be drawn.

    Declaration
    public Stretch Stretch { get; set; }
    Property Value
    Type Description
    Stretch

    StretchDirection

    Gets/Sets the stretch direction of the ViewBox, which determines the restrictions on scaling that are applied to the content inside the ViewBox. For instance, this property can be used to prevent the content from being smaller than its native size or larger than its native size.

    Declaration
    public StretchDirection StretchDirection { get; set; }
    Property Value
    Type Description
    StretchDirection

    UnloadedBehavior

    Specifies how the underlying media engine's resources should be handled when the unloaded event gets fired. The default behavior is to Close and release the resources.

    Declaration
    public MediaPlaybackState UnloadedBehavior { get; set; }
    Property Value
    Type Description
    MediaPlaybackState

    VerticalSyncEnabled

    Gets or sets a value that indicates whether the MediaElement will update frames for seek operations while paused. This is a dependency property.

    Declaration
    public bool VerticalSyncEnabled { get; set; }
    Property Value
    Type Description
    Boolean

    Volume

    Gets/Sets the Volume property on the MediaElement. Note: Valid values are from 0 to 1.

    Declaration
    public double Volume { get; set; }
    Property Value
    Type Description
    Double

    Methods

    CaptureBitmapAsync()

    Captures the currently displayed video image and returns a GDI bitmap.

    Declaration
    public ConfiguredTaskAwaitable<Drawing.Bitmap> CaptureBitmapAsync()
    Returns
    Type Description
    ConfiguredTaskAwaitable<Drawing.Bitmap>

    The GDI bitmap copied from the video renderer.

    Dispose()

    Declaration
    public void Dispose()

    Events

    AudioDeviceStopped

    Occurs when the currently selected audio device stops or loses its buffer. Call the method and select a new audio device in order to output to a new audio device

    Declaration
    public event EventHandler AudioDeviceStopped
    Event Type
    Type Description
    EventHandler

    FFmpegMessageLogged

    Occurs when a logging message from the FFmpeg library has been received. This is shared across all instances of Media Elements.

    Declaration
    public static event EventHandler<MediaLogMessageEventArgs> FFmpegMessageLogged
    Event Type
    Type Description
    EventHandler<MediaLogMessageEventArgs>
    Remarks

    This event is raised on a background thread. All interaction with UI elements requires calls on their corresponding dispatcher.

    RenderingAudio

    Occurs right before the audio is added to the audio buffer. You can update the bytes before they are queued. Ensure you handle this quickly before you get choppy audio.

    Declaration
    public event EventHandler<RenderingAudioEventArgs> RenderingAudio
    Event Type
    Type Description
    EventHandler<RenderingAudioEventArgs>

    RenderingSubtitles

    Occurs right before the subtitles are rendered. You can update the text. Ensure you handle this quickly before you get choppy subtitles.

    Declaration
    public event EventHandler<RenderingSubtitlesEventArgs> RenderingSubtitles
    Event Type
    Type Description
    EventHandler<RenderingSubtitlesEventArgs>

    RenderingVideo

    Occurs right before the video is presented on the screen. You can update the pixels on the bitmap before it is rendered on the screen. Or you could take a screen shot. Ensure you handle this very quickly as it runs on the UI thread.

    Declaration
    public event EventHandler<RenderingVideoEventArgs> RenderingVideo
    Event Type
    Type Description
    EventHandler<RenderingVideoEventArgs>

    Implements

    IUriContext
    System.IDisposable

    Comments

    Back to top Copyright © 2017-2019 Unosquare