ESL Media

ESLMedia is a custom element, that provides an ability to add and configure media (video / audio) using a single tag as well as work with external providers using simple native-like API.


Supported Features

Provides 'HTMLMedia like' API that is safe and will be executed after real API is ready.

ESLMedia supports different media providers

Out of the box providers

ESLMedia module provides out-of-the-box support for the following media providers: - audio type - provided by AudioProvider which renders native HTMLAudioElement - video type - provided by VideoProvider which renders native HTMLVideoElement

- youtube type - provided by YoutubeProvider which renders Youtube video player - brightcove type - provided by BrightcoveProvider which renders videojs video player (with Brightcove plugin applied)

- iframe type - abstract fallback provider (IframeProvider) which renders native HTMLIFrameElement. Does not support control commands and in pause state excludes iframe from the DOM.

Custom providers

ESLMedia module provides an ability to add custom media providers. You should use BaseProvider class to create a custom provider. BaseProvider class requires to implement all abstract methods and properties. Also note that a custom provider should call following hooks manually

ESLMedia supports wide range of initialization and state management features

Lazy & Manual loading

ESLMedia supports lazy attribute that provides two modes of custom media loading:

Load condition

ESLMedia supports load-condition attribute that restricts loading of media resources based on the given condition. Attribute uses ESLMediaQuery syntax.

Play in viewport restriction

In case of play-in-viewport attribute is set, ESLMedia will automatically stop media playback when it is out of the viewport area, and resume playback when it returns to the viewport.

Group restriction

ESLMedia supports group attribute that restricts the number of active media players in the given group.

Container control

ESLMedia supports ESLToggleable container state observation. When the container is opened, the media player with autoplay attribute allowed to be started. When the container is closed, the media player inside it will be automatically paused.

Initialization hook and instance manager

ESLMedia dispatches esl:media:before:play cancelable event in the following cases:

In addition ESLMedia.property.manager holds ESLMediaManager instance (singleton by default) that controls all media instances that are referencing the same manager instance. The esl:media:managedaction event could be dispatched on the window to call manager resume/suspend methods indirectly.

Commands initiator control

ESLMedia commands divided to user-related and system-related. User-related commands have higher priority and override system-related commands. All automatic features like play-in-viewport and autoplay utilize system-related commands, so manual user interaction will have higher priority.

State attributes, classes and events

ESLMedia dispatches a set of events to notify about media state changes. Also, ESLMedia provides attributes to reflect media state and additional classes that could be attached via load-condition-class attribute with support of ESLClassUtils syntax and load-condition-class-target attribute with support of ESLTraversingQuery syntax.

Fill mode support

API:

Attributes:

Deprecated attributes (going to be removed in 5.0.0):

Readonly Attributes:

Events:

Examples:

<esl-media
    media-type="youtube"
    media-id="##MEDIAID##"
    title="Video Title"     
    disabled 
    group="mediaGroup"
></esl-media>