akamai.amp.Player
The base player class.
Constructor
Player
new Player()
Extends
Members
absoluteCurrentTime
:number
The playhead time in seconds without any time transformations applied.
absoluteDuration
(readonly) :number
The duration of the video in seconds without any time transformations applied.
audioTracks
(readonly) :akamai.amp.TrackList
A list of audio tracks associated with the current video.
autoplay
:boolean
The autoplay flag.
bottom
(readonly) :number
The bottom position of the player container in pixels.
buffering
(readonly) :boolean
The buffering flag.
busy
:boolean
The player's busy state. Used to show the busy UI for situations outside of the video waiting
event.
chapterTracks
(readonly) :akamai.amp.TrackList
A list of chapter tracks associated with the current media object.
container
:HTMLElement
The player's container div.
controls
:boolean
Show/hide browses default video controls.
cues
:Array.<akamai.amp.Cue>
A list of cue points associated with the video content.
currentTime
:number
The current time of the video in seconds. Used to seek or retrive the playhead time.
debug
(readonly) :boolean
Indicates whether or not the player is operating in debug mode.
defaultMediaTransform
(readonly) :function
The default media transformation.
duration
(readonly) :number
The duration of the video in seconds.
ended
(readonly) :boolean
Indicates whether or not the player has reached the end of content
error
(readonly) :Error
The last error the player encountered since loading the video content
height
(readonly) :number
The height of the player container in pixels.
hidden
:boolean
Flag indicating whether the player is showing or hidden.
isLive
(readonly) :boolean
Indicates whether or not the stream is playing at the live edge.
language
:string
The player language (IETF language tag). Used to localize UI text and set default caption language.
left
(readonly) :number
The left position of the player container in pixels.
loop
:boolean
The loop flag.
maxBitrate
:number
The maximum bitrate in bits per second selectable by the player. This value is resetted when a quality level is manually selected.
- Default Value:
- -1 no limit
maxQualityLevel
:number
Returns the maximum level index that player can select. Gets -1 for no limit.
maxQualityLevel
- Deprecated:
- use maxBitrate instead
mediaElement
(readonly) :HTMLObject|HTMLMediaElement
The media playback DOM element.
mouseOver
(readonly) :boolean
The mouse over flag.
mouseX
(readonly) :number
The x position of the mouse within the player container in pixels.
mouseY
(readonly) :number
The y position of the mouse within the player container in pixels.
muted
:boolean
The player's muted value.
params
:Object
Customer provided parameters.
paused
(readonly) :boolean
Indicates whether or not the player is paused
playbackRate
:number
The playback rate. 1 represents normal playback speed, 2 double speed, 0.5 half speed, etc.
playbackTarget
:string
The playback target of the video content. i.e. "amp", "chromecast", "airplay", etc.
previewTracks
(readonly) :akamai.amp.TrackList
A list of preview tracks associated with the current video.
quality
:number
The current quality level (bitrate).
qualityLevels
(readonly) :Array
A list of available quality levels associated with the video content.
right
(readonly) :number
The right position of the player container in pixels.
seeking
(readonly) :boolean
Indicates whether or not the player is seeking
src
:string
The source url of the video to play.
textTracks
(readonly) :akamai.amp.TrackList
A list of text tracks associated with the current video.
top
(readonly) :number
The top position of the player container in pixels.
version
(readonly) :string
The player version
videoHeight
(readonly) :number
The encoded height of the video content currently playing in pixels.
videoWidth
(readonly) :number
The encoded width of the video content currently playing in pixels.
volume
:number
The player's volume. Must be a number between 0 and 1.
waiting
(readonly) :boolean
Flag indicating whether or not the player is waiting for media content.
width
(readonly) :number
The width of the player container in pixels.
Methods
addEventListener
addEventListener(typenon-null, funcnon-null)
Adds a listener for a given event type.
Parameters
Name | Type | Description |
---|---|---|
type |
string | A string representing the event's type. |
func |
function | A function to call when the event is triggered. |
- Inherited From:
addListener
addListener()
Alias of addEventListener
- Inherited From:
addTransform
addTransform(typenon-null, transform)
Adds a transform for a given type.
Parameters
Name | Type | Description |
---|---|---|
type |
string | A string representing the event's type. |
transform |
function | akamai.amp.Transform | A function to call when the event is triggered. |
- Tutorials:
-
- Tutorial: {6-media-transforms}
- See:
canPlayType
canPlayType(type) → {string}
Determines if the core can play a given mimeType.
Parameters
Name | Type | Description |
---|---|---|
type |
string | The mimetype to check. |
Returns
- string
destroy
destroy() → {Promise}
Destroys the player.
- Overrides:
Returns
- Promise
-
Promise which resolves once the player has been destroyed.
dispatch
dispatch(type, detailopt)
Dispathes and event, triggering all event listener of the event's type.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | The event to type. |
|
detail |
Object |
<optional> |
Object representing event specific details. |
- Inherited From:
dispatchEvent
dispatchEvent(eventnon-null)
Dispathes and event, triggering all event listener of the event's type.
Parameters
Name | Type | Description |
---|---|---|
event |
Event | The event to dispatch. |
- Inherited From:
end
end()
Ends video playback.
enterFullScreen
enterFullScreen()
Enters the player into full screen mode.
enterPictureInPicture
enterPictureInPicture()
Enters the player into picture in picture mode.
evaluateBindings
evaluateBindings(binding) → {Object}
Parameters
Name | Type | Description |
---|---|---|
binding |
Object | A data bound string or object to evaluate. |
Returns
- Object
-
The evaluated result
exitFullScreen
exitFullScreen()
Exits the player out of full screen mode.
exitPictureInPicture
exitPictureInPicture()
Exits the player out of picture in picture mode.
fromUTC
fromUTC(value) → {number}
Converts a playhead time from UTC to seconds if available
Parameters
Name | Type | Description |
---|---|---|
value |
number | The playhead time in UTC |
Returns
- number
-
The playhead time in seconds
getLocalizedString
getLocalizedString(value, contextopt) → {string}
Get a localized string.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
value |
string | The localized string id |
|
context |
context |
<optional> |
A context object providing additional variable to bound templates |
Returns
- string
-
The localized string
goLive
goLive()
Forces to stream to play from the live edge.
load
load()
Loads the video.
loadResources
loadResources(resources, callback) → {Promise}
Loads a list of JS and CSS resources.
Parameters
Name | Type | Description |
---|---|---|
resources |
Array.<akamai.amp.Resource> | The list of js and css resources |
callback |
function |
Returns
- Promise
-
Promise which resolves once all resources have been loaded.
mute
mute()
Mutes the player.
once
once(typenon-null, funcnon-null)
Adds a listener for a given event type that is called once, then removed.
Parameters
Name | Type | Description |
---|---|---|
type |
string | A string representing the event's type. |
func |
function | A function to call when the event is triggered. |
- Inherited From:
pause
pause() → {Promise}
Pauses the currently loaded video.
Returns
- Promise
play
play() → {Promise}
Plays the currently loaded video.
Returns
- Promise
recordContentChange
recordContentChange(content)
Records a content change
Parameters
Name | Type | Description |
---|---|---|
content |
Object | An object representing the new content |
removeEventListener
removeEventListener(typenon-null, funcnon-null) → (nullable) {function}
Removes a listener for a given event type.
Parameters
Name | Type | Description |
---|---|---|
type |
string | A string representing the event's type. |
func |
function | A function to call when the event is triggered. |
- Inherited From:
Returns
- function
-
the handler that was removed if any
removeListener
removeListener()
Alias of removeEventListener
- Inherited From:
removeTransform
removeTransform(typenon-null, transform) → {function|akamai.amp.Transform}
Removes a transform for a given type.
Parameters
Name | Type | Description |
---|---|---|
type |
string | A string representing the tranform's type. |
transform |
function | akamai.amp.Transform | A function or Transform object to call when the type is triggered. |
- See:
Returns
- function | akamai.amp.Transform
-
the transform that was removed if any
replay
replay()
Plays the currently loaded video from its start time.
request
request(options) → {Promise.<XHR>}
Request a http resource.
Parameters
Name | Type | Description |
---|---|---|
options |
string | akamai.amp.Request | A url object or string. |
Returns
- Promise.<XHR>
-
Promise which resolves to a XHR object
seek
seek(value) → {Promise.<number>}
Sets the current time of the video.
Parameters
Name | Type | Description |
---|---|---|
value |
The playhead time in seconds |
Returns
- Promise.<number>
sortTransforms
sortTransforms(typenon-null, sortopt) → {Array.<(function()|akamai.amp.Transform)>}
Sorts the transform list by priority. Higher priority Transforms are executed first.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | The tranform type |
|
sort |
function |
<optional> |
An optional sort function |
- See:
Returns
- Array.<(function()|akamai.amp.Transform)>
-
The sorted list of transforms
toUTC
toUTC(value) → {number}
Converts a playhead time from seconds to UTC if available
Parameters
Name | Type | Description |
---|---|---|
value |
number | The playhead time in seconds |
Returns
- number
-
The playhead time in UTC
transform
transform(typenon-null, valuenon-null) → {Promise}
Performs a transform for a given type
Parameters
Name | Type | Description |
---|---|---|
type |
string | The tranform type |
value |
Object | The value to be transformed |
- See:
Returns
- Promise
unmute
unmute()
Unmutes the player.