Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Media

Media element.

description

Class that creates the Media Component in the player. Media is the visual/audio entity that results from playing a valid source (MP4, MP3, M3U8, MPD, etc.)

class

Media

Hierarchy

  • Media

Index

Constructors

constructor

  • Create an instance of Media.

    memberof

    Media

    Parameters

    Returns Media

Properties

element

element: HTMLMediaElement

The video/audio tag that contains media to be played.

type

HTMLMediaElement

memberof

Media

media

Object that instantiates class of current media.

type

(HTML5Media|HlsMedia|DashMedia)

memberof

Media

mediaFiles

mediaFiles: Source[]

Collection of media sources available within the video/audio tag.

type

Source[]

memberof

Media

Private options

options: PlayerOptions

Media options to be passed to Hls and/or Dash players.

type

PlayerOptions

memberof

Media

Private promisePlay

promisePlay: Promise<void>

Promise to be resolved once media starts playing to avoid race issues.

see

Media.play

see

Media.pause

type

Promise

memberof

Media

Accessors

currentTime

  • get currentTime(): number
  • set currentTime(value: number): void

duration

  • get duration(): number

ended

  • get ended(): boolean

muted

  • get muted(): boolean
  • set muted(value: boolean): void

paused

  • get paused(): boolean

playbackRate

  • get playbackRate(): number
  • set playbackRate(value: number): void

src

volume

  • get volume(): number
  • set volume(value: number): void

Methods

Private _getMediaFiles

  • Gather all media sources within the video/audio/iframe tags.

    It will be grouped inside the mediaFiles array. This method basically mimics the native behavior when multiple sources are associated with an element, and the browser takes care of selecting the most appropriate one.

    memberof

    Media

    Returns Source[]

Private _invoke

Private _loadSources

  • _loadSources(sources: Source[]): void
  • Load the first playable source from one or many sources available in the video/audio tag.

    If none of them can be played, automatically the method destroys the Media object.

    memberof

    Media

    Parameters

    Returns void

canPlayType

  • canPlayType(mimeType: string): boolean
  • Check if player can play the current media type (MIME type).

    see

    Native.canPlayType

    Parameters

    • mimeType: string

      A valid MIME type, that can include codecs.

    Returns boolean

destroy

  • destroy(): void
  • Invoke destroy method of current media type.

    Streaming that uses hls.js or dash.js libraries require to destroy their players and their custom events.

    memberof

    Media

    Returns void

load

  • load(): void
  • Check media associated and process it according to its type.

    It requires to run with Promises to avoid racing errors between execution of the action and the time the potential libraries are loaded completely. It will loop the media list found until it reached the first element that can be played.

    see

    Native.load

    Returns void

pause

  • pause(): void

play

  • play(): Promise<void>

Generated using TypeDoc