Constructor
new MediaBagElement(basePath, file, zipopt)
MediaBagElement constructor
Name | Type | Attributes | Description |
---|---|---|---|
basePath | string | Path to be used as a prefix of the file name | |
file | string | The media file name | |
zip | external:JSZip | <optional> | An optional JSZip object from which the file must be extracted. |
- Source
Members
animated :boolean
Flag used for animated GIFs
- boolean
- Source
basePath :string
The path to be used as base to access this media element
- string
- Source
data :object
When loaded, this field will store the realized media object
- object
- Source
ext :string
Normalized extension of file
, useful to guess the media type
- string
- Source
file :string
The name of the file where this element is stored
- string
- Source
fontName :string
The font family name, used only in elements of type 'font'
- string
- Source
name :string
The name of this element. Usually is the same as file
- string
- Source
ready :boolean
Flag indicating that data
is ready to be used
- boolean
- Source
timeout :number
Time set to load the resource before leaving
- number
- Source
type :string
The resource type ('audio', 'image', 'midi', 'video', 'font')
- string
- Source
zip :external:JSZip
An optional JSZip object that can act as a container of this media
- Source
Methods
_onReady()
Notify listeners that the resource is ready
- Source
build(callback, ps, force, level)
Instantiates the media content
Name | Type | Default | Description |
---|---|---|---|
callback | function | Callback method called when the referred resource is ready | |
ps | module:JClicPlayer. | null | An optional |
force | boolean | false | Used only in media of type 'audio'. When |
level | number | 1 | Priority level of the media content to be built. Used only n audio elements. |
- Source
checkAnimatedGif()
Checks if the image associated with this MediaBagElement is an animated GIF
Based on: https://gist.github.com/marckubischta/261ad8427a214022890b
Thanks to @lakenen
and @marckubischta
- Source
checkReady() → {boolean}
Checks if this media element is ready to start
- Source
true
if ready,false
otherwise
- Type:
- boolean
checkTimeout() → {boolean}
Checks if this resource has timed out.
- Source
true
if the resource has exhausted the allowed time to load,false
otherwise
- Type:
- boolean
getAttributes() → {object}
Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.
- Source
- The resulting object, with minimal attrributes
- Type:
- object
getFileType(ext) → {string}
Determines the type of a file from its extension
Name | Type | Description |
---|---|---|
ext | string | The file name extension |
- Source
- Type:
- string
getFullPath() → {string}
Gets the full path of the file associated to this element.
WARNING: This function should be called only after a successful call to getFullPathPromise
- Source
- Type:
- string
getFullPathPromise() → {external:Promise}
Gets a promise with the full path of the file associated to this element.
- Source
- Type:
- external:Promise
isEmpty() → {boolean}
Checks if the MediaBagElement has been initiated
- Source
- Type:
- boolean
setAttributes(data)
Loads the element properties from a data object
Name | Type | Description |
---|---|---|
data | object | The data object to parse |
- Source
setProperties($xml)
Loads this object settings from a specific JQuery XML element
Name | Type | Description |
---|---|---|
$xml | external:jQuery | The XML element to parse |
- Source
(static) getAudioPlayer(level) → {external:HTMLAudioElement}
Gets the static HTMLAudioElement
associated to the requested priority level.
Name | Type | Default | Description |
---|---|---|---|
level | number | 1 | The priority level |
- Source
(static) resetAudioElements()
Clear all references to audio players and audio elements
To be called when a new activity starts
- Source