MediaProvider

MediaProvider

This provider (singleton) takes care of loading, parsing and providing external media content (image, json).

Constructor

new MediaProvider()

Source:

Extends

  • EventTarget

Members

autoStoreSources

Description:
  • Setter

Source:

Setter

autoStoreSources

Description:
  • Getter

Source:

Getter

(private) autoStoreSources_ :boolean

Description:
  • Defines if all load promises should be stored in the source list.

Source:

Defines if all load promises should be stored in the source list.

Type:
  • boolean

mediaAssetPath

Description:
  • Setter

Source:

Setter

mediaAssetPath

Description:
  • Getter

Source:

Getter

(private) mediaAssetPath_ :string

Description:
  • Relative default asset path.

Source:

Relative default asset path.

Type:
  • string

mediaAssetUrl

Description:
  • Getter

Source:

Getter

(private) mediaAssetUrl_ :string

Description:
Source:

It is an absolute asset URL if the variable window.ASSET_URL is set, otherwise it is the relative MediaProvider#mediaAssetPath_.

Type:
  • string

(private) sources_ :Map.<string, Promise>

Description:
  • List of stored loading promises, where key ist the file path.

Source:

List of stored loading promises, where key ist the file path.

Type:
  • Map.<string, Promise>

Methods

(private) getResponseType_(loadType) → {string}

Description:
  • Gets the response type by the given load type

Source:
Parameters:
Name Type Description
loadType
Returns:
Type
string

getSource(key) → {Promise}

Description:
  • Retrieve a source by key (file path). If the source has not been loaded yet, load it.

Source:
Parameters:
Name Type Description
key string
Returns:
Type
Promise

load(source, additionalPathSegmentopt, loadType, storeSourceopt, preventCDNServiceopt) → {Promise}

Description:
  • Loads a media source and returns a promise that is fulfilled when the source is loaded.

Source:
Parameters:
Name Type Attributes Default Description
source Array.<string> | string

path

additionalPathSegment string <optional>

additional path segment between MediaProvider#mediaAssetPath_ and the given source.

loadType string | null null

Loading type like json or blob. If nothing is specified, the file extension is analyzed to determine the loading method.

storeSource boolean <optional>
false

Store loading promise in the MediaProvider#sources_ list.

preventCDNService boolean <optional>
false

Prevent loading over a cdn url, which is part of MediaProvider#mediaAssetUrl_. Loading path will be relative stating with MediaProvider#mediaAssetPath_.

Returns:
Type
Promise

(private) loadImage_(url, preventCDNServiceopt) → {Promise}

Description:
  • Loading an image and returns a promise that is fulfilled when the source is loaded.

Source:
Parameters:
Name Type Attributes Default Description
url string
preventCDNService boolean <optional>
false

Prevent loading over a cdn url, which is part of MediaProvider#mediaAssetUrl_. Loading path will be relative stating with MediaProvider#mediaAssetPath_.

Returns:
Type
Promise

(private) loadJson_(url, preventCDNServiceopt) → {Promise}

Description:
  • Loading a json and parse the result as a json object. Returns a promise that is fulfilled when the source is loaded.

Source:
Parameters:
Name Type Attributes Default Description
url string

Source path

preventCDNService boolean <optional>
false

Prevent loading over a cdn url, which is part of MediaProvider#mediaAssetUrl_. Loading path will be relative stating with MediaProvider#mediaAssetPath_.

Returns:
Type
Promise

(private) load_(url, responseTypeopt, preventCDNServiceopt) → {Promise}

Description:
  • Loading a source and returns a promise that is fulfilled when the source is loaded.

Source:
Parameters:
Name Type Attributes Default Description
url string

Source path

responseType string <optional>

Optional xhr response type

preventCDNService boolean <optional>
false

Prevent loading over a cdn url, which is part of MediaProvider#mediaAssetUrl_. Loading path will be relative stating with MediaProvider#mediaAssetPath_.

Returns:
Type
Promise