new Player(tag [, options] [, ready])
Player class, inherits from videojs Player class.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
tag |
Element | The original video tag used for configuring options |
|
options |
Object |
<optional> |
Player Options |
ready |
function |
<optional> |
Ready callback |
Extends
- videojs.Player
Members
-
entitlement
-
Get entitlement
-
isProgramEvent
-
Is current program an event
-
streamType
-
Get StreamType (DASH OR HLS OR SMOOTHSTREAMING)
-
version
-
Get version
Methods
-
<static> AutoTechArray(chosenDashTech)
-
Get AutoTechArray
Parameters:
Name Type Description chosenDashTech
string choice of dash tech
Returns:
AutoTechArray
- Type
- Array.<string>
-
<static> SupportFairplay()
-
Check if the browser and plattform support Fairplay
Returns:
True if the browser and plattform support Fairplay
- Type
- boolean
-
baseCurrentTime()
-
Get or the raw current time (in seconds) from the video element
NOTE: It's the raw currentTime from the video element
Returns:
- the current time in seconds when getting
- Type
- number
-
baseDuration( [seconds])
-
Normally gets the length in time of the video in seconds;
in all but the rarest use cases an argument will NOT be passed to the methodNOTE: It's the raw duration from the video element
NOTE: The video must have started loading before the duration can be
known,
playing.Parameters:
Name Type Argument Description seconds
number <optional>
The duration of the video to set in seconds
Fires:
- Player#event:durationchange
Returns:
- The duration of the video in seconds when getting
- Type
- number
-
bitrate(value)
-
Get/Set bitrate
Will always return a bitrate equal to the current video bitrate. However it may change due to dynamic switching.
Setting this value disable dynamic switching, and fixes the bitrate as specified.
To set a ceiling, but allow it to dynamically switch quality when
able use setMaxBitrate insteadParameters:
Name Type Description value
number Bitrate to set
Returns:
bitrate when getting
- Type
- number
-
bitrates()
-
Returns a list of available bitrates
Returns:
) Array of available bitrates
- Type
- Array.<number>
-
buffered()
-
Get a program related
TimeRange
object for buffering.Returns:
The time range object.
- Type
- TimeRange
-
canEnableTimeshift()
-
Can timeShift be enabled according to contract restriction
Returns:
Can Enable Timeshift
- Type
- boolean
-
canRestart()
-
Can video or program restart from begining
Returns:
Can Restart
- Type
- boolean
-
canSeekTo(position)
-
Can Seek To position
Parameters:
Name Type Description position
number Returns:
Can Seek To
- Type
- boolean
-
currentAsset()
-
Get current video source asset object
Returns:
video source asset object { 'assetId': assetId, 'programId': programId, 'channelId': channelId }
- Type
- Object
-
currentTime( [seconds])
-
Get or set the current time (in seconds) for the program or video
Parameters:
Name Type Argument Description seconds
number | string <optional>
The time to seek to in seconds
Returns:
- the current time in seconds when getting
- Type
- number
-
disableTimeShift(value)
-
Set / Get timeShift disable
NOTE: For backward compatibility, use timeShiftEnabled.
Parameters:
Name Type Description value
boolean true=disable false=enabled
Returns:
true if timeShift is disable
- Type
- boolean
-
driftingTime()
-
The time (s) the live stream has drifted
Returns:
drifting Time or NaN
- Type
- number
-
duration( [seconds])
-
Gets the length in time of the video or program in seconds;
in all but the rarest use cases an argument will NOT be passed to the methodNOTE: The video must have started loading before the duration can be
known.Parameters:
Name Type Argument Description seconds
number <optional>
The duration of the video to set in seconds
Fires:
- Player#event:durationchange
Returns:
- The duration of the video in seconds when getting
- Type
- number
-
ended()
-
Check if video has ended
Returns:
true if Video has ended
- Type
- boolean
-
error(err)
-
Set the player in error state or clear error with null
Parameters:
Name Type Description err
Object | string The error or null for clear error
Returns:
The current Error
- Type
- Object | string
-
getAbsoluteTime()
-
Get the playheadTime as a Date
Returns:
playheadTime
- Type
- Date
-
getAssetDetails()
-
Get Asset/VOD Details
Returns:
Asset/VOD Details
- Type
- Object
-
getAudioTracksLanguages()
-
Get all Audio track language codes
Returns:
Array of language codes
- Type
- Array.<strings>
-
getAvalibleTechs_(excludeTechs)
-
Get Avalible Techs
Parameters:
Name Type Description excludeTechs
Object Returns:
Avalible Techs
- Type
- Array
-
getBitrate()
-
Get current bitrate
Always returns the current bitrate, unlike bitrate() which returns 0 if ABR is enabled
Returns:
bitrate when getting
- Type
- number
-
getBufferedTimerange()
-
Get a unix time (ms)
TimeRange
object for buffering.Returns:
The time range object.
- Type
- TimeRange
-
getCurrentTechName()
-
Get Current Tech Name
Returns:
Current Tech Name
- Type
- string
-
getError()
-
Get current Error
Returns:
Error object
- Type
- Object
-
getExposure()
-
Get current Exposure
Returns:
Exposure
- Type
- Exposure
-
getGrowingLiveDuration()
-
Get a growing (program based) live duration
Returns:
- The duration of the video in seconds when getting
- Type
- number
-
getMaxBitrate()
-
Get Max Bitrate
Returns:
Max Bitrate
- Type
- number
-
getMediaInfo()
-
Get MediaInfo
Returns:
MediaInfo (title, subtitle, images, channel-title, channel-images)
- Type
- Object
-
getProgram( [callback])
-
getProgram
NOTE: For backward compatibility only.
Parameters:
Name Type Argument Description callback
function <optional>
Callback with the program
- Deprecated:
-
- since version 1 use getProgramDetails instead
-
getProgramDetails()
-
Get Program Details
Returns:
Program Details
- Type
- Object
-
getRestrictions()
-
Get Contract Restrictions
Returns:
Contract Restrictions
- Type
- Object
-
getSeekTimerange()
-
Get a unix time (ms)
TimeRange
object for seekable range.Returns:
The time range object.
- Type
- TimeRange
-
getSelectedAudioTrack()
-
get languageCode for current Audio Track (en, sv, de ...)
Returns:
languageCode
- Type
- string
-
getSelectedTextTrack()
-
get languageCode for current Text Track (null, en, sv, de ...)
Returns:
languageCode or null
- Type
- string
-
getServerTime()
-
Get Server Now Time
Returns:
ServerTime
- Type
- number
-
getTextTracksLanguages()
-
Get all text track language codes
Returns:
Array of language codes
- Type
- Array.<string>
-
gotoBeginning()
-
Jump to the Beginning
-
gotoLive()
-
Jump to the live edge
-
isAudioOnly()
-
Check if tream is only Audio
Returns:
true stream is only Audio
- Type
- boolean
-
isCasting()
-
Check if player is connected to Chromecast
Returns:
true if casting
- Type
- boolean
-
isLive()
-
Is playback a live stream
Returns:
isLive
- Type
- boolean
-
isPlaying()
-
Has the playback started
-
NOTE: True if paused
Returns:
Is video playing
- Type
- boolean
-
-
isProgramCatchup()
-
Is the playing program a Catchup
Returns:
Is program a catchup
- Type
- boolean
-
isProgramLive()
-
Is the playing program live
Returns:
is Program Live
- Type
- boolean
-
isTextTrackVisible()
-
Is text track is visible
Returns:
Is the TextTrack Visible
- Type
- boolean
-
lineUpAsset(assetId, channelId, programId, startTime, noPlaylist)
-
Add a asset/program to the playback queue
Parameters:
Name Type Argument Description assetId
string <nullable>
optional
channelId
string <nullable>
optional
programId
string <nullable>
optional
startTime
number <nullable>
optional startTime in unix time (ms)
noPlaylist
boolean <nullable>
optional If the lineUpAsset should not be played as Playlist asset
-
lineupSource( [source])
-
Add video source to the playback queue
Parameters:
Name Type Argument Description source
Tech~SourceObject | Array.<Tech~SourceObject> | string <optional>
A SourceObject, or a string referencing URL to a media source.
-
liveDelay()
-
get live delay, how many seconds player live edge differ fom server time
Returns:
live delay in seconds
- Type
- number
-
loadAsset(assetId [, programId] [, callback])
-
Load an asset for playback
Parameters:
Name Type Argument Description assetId
string Identifier of the asset or channel to load
programId
string <optional>
(optional) Identifier of the program to load
callback
function <optional>
Callback when entitlement request has completed
- Deprecated:
-
- since version 1, use startPlayback() or src() instead
-
loadNextSource()
-
load and play next video/program in the playback queue
Returns:
True if there was something in the queue
- Type
- boolean
-
noEPG()
-
No EPG for current program
Returns:
current program has no EPG
- Type
- boolean
-
options(obj)
-
Set/Get The player options
Parameters:
Name Type Description obj
Object Returns:
options
- Type
- Object
-
playbackRate( [rate])
-
Gets or sets the current playback rate. A playback rate of
1.0 represents normal speed and 0.5 would indicate half-speed
playback, for instance.Parameters:
Name Type Argument Description rate
number <optional>
New playback rate to set.
Returns:
The current playback rate when getting or 1.0
- Type
- number
-
playEntitlement(entitlement)
-
Plays an entitlement
Automatically select a playback tech based on the entitlement and prepares playback.
Parameters:
Name Type Description entitlement
Object Entitlement returned from entitlementengine
-
playheadTime(unixTime)
-
Set / Get the play head time unix time (ms)
Parameters:
Name Type Description unixTime
number Returns:
playheadTime
- Type
- number
-
playNextProgram()
-
Play Next Program
-
playPreviousProgram(end)
-
Play Previous Program
Parameters:
Name Type Description end
boolean If it should play 30 sec from the end
-
remainingTime()
-
Get remaining time of the program/vod
Returns:
remaining time
- Type
- number
-
reset()
-
Reset the tech by removing all sources and then calling
Html5.resetMediaElement. -
resetAndRestartFormPlayhead(reset)
-
Reset and restart form current playhead position
Parameters:
Name Type Default Description reset
boolean true = true
-
resetControlBarUI_()
-
Reset Control Bar's UI by calling sub-methods that reset
all of Control Bar's components -
restart(useLastViewedOffset, startTime)
-
Restart the program from beginning or with LastViewedOffset
Parameters:
Name Type Argument Description useLastViewedOffset
boolean <nullable>
optional start from last viewed offset
startTime
number <nullable>
optional startTime in unix time (ms)
-
restartFormPlayhead()
-
Restart form current playhead position
-
seekable()
-
Get a program related
TimeRange
object for seekable range.Returns:
The time range object.
- Type
- TimeRange
-
seekable()
-
Returns the TimeRanges of the media that are currently available
for seeking to.Returns:
the seekable intervals of the media timeline
- Type
- TimeRanges
-
seekable()
-
Returns the TimeRanges of the media that are currently available
for seeking to.Returns:
the seekable intervals of the media timeline
- Type
- TimeRanges
-
seekable()
-
Returns the TimeRanges of the media that are currently available
for seeking to.Returns:
the seekable intervals of the media timeline
- Type
- TimeRanges
-
seekable()
-
Returns the TimeRanges of the media that are currently available
for seeking to.Returns:
the seekable intervals of the media timeline
- Type
- TimeRanges
-
seekable()
-
Returns the TimeRanges of the media that are currently available
for seeking to.Returns:
the seekable intervals of the media timeline
- Type
- TimeRanges
-
selectAudioTrack(languageCode, kind)
-
select audio track with languageCode (en, sv, de ...) and optional kind
Parameters:
Name Type Description languageCode
string kind
string or empty
-
selectTextTrack(languageCode, kind)
-
select text track with languageCode (en, sv, de) and optional kind
Parameters:
Name Type Argument Description languageCode
string <nullable>
or null
kind
string <nullable>
or empty
-
setAbsoluteTime(date)
-
Set the playheadTime as a Date
Parameters:
Name Type Description date
Date -
setAnalyticsCustomAttribute(key [, value])
-
Sets analytics custom attributes
Parameters:
Name Type Argument Description key
string Attribute name
value
string <optional>
Attribute value
-
setMaxBitrate(bitrate)
-
Set Max Bitrate
Parameters:
Name Type Description bitrate
number -
setTextTrackStyle(style)
-
set videojs TextTrackStyle or send to Chromecast
Parameters:
Name Type Description style
Object -
sourceChanging()
-
Video Source is changing
Returns:
true if video source is changing
- Type
- boolean
-
src( [source])
-
Get or set the video source.
Parameters:
Name Type Argument Description source
Tech~SourceObject | Array.<Tech~SourceObject> | string <optional>
A SourceObject, an array of SourceObjects, or a string referencing
a URL to a media source. It is highly recommended that an object
or array of objects is used here, so that source selection
algorithms can take thetype
into account.If not provided, this method acts as a getter.
Returns:
If the
source
argument is missing, returns the current source
URL. Otherwise, returns nothing/undefined.- Type
- string | undefined
-
startPlayback(assetId, channelId, programId, playbackProperties)
-
Load an asset for playback
Parameters:
Name Type Description assetId
any Identifier of the asset to load (VOD, Channel or Program)
channelId
any (optional) Identifier of the channel to load
programId
any (optional) Identifier of the program to load (channelId is mandatory with programId)
playbackProperties
any (optional) Playback properties
-
startPlaybackV2(assetId, playbackProperties)
-
Load an asset for playback
Parameters:
Name Type Description assetId
any Identifier of the asset to load (VOD, Channel or Program)
playbackProperties
any (optional) Playback properties
-
startProgramService()
-
Start the Program Service
-
startTimeLive()
-
The unix time (ms) when stream was started
Returns:
Start Time Live
- Type
- number
-
stopProgramService()
-
Stop the Program Service
-
supportsEpgProgramChange()
-
Supports Epg Program Change
NOTE: For backward compatibility only.
Returns:
True if programService is available
- Type
- boolean
-
syncServerTime( [callback])
-
Sync localtime with servertime
Parameters:
Name Type Argument Description callback
function <optional>
Callback when localtime sync with servertime or an error occurs
-
techVersion()
-
Get the current tech verion
Returns:
the version number
- Type
- string
-
textTrackVisible(visible)
-
Hide or Show Text tracks
Parameters:
Name Type Description visible
boolean -
timeBehindLive()
-
seconds behinde live edge
Returns:
timeBehindLive
- Type
- number
-
timeShiftEnabled(value)
-
Get or Set timeShiftEnabled
Parameters:
Name Type Description value
boolean Returns:
is timeShift enabled
- Type
- boolean
-
updateSourceCaches_(srcObj)
-
Update the internal source caches so that we return the correct source from
src()
,currentSource()
, andcurrentSources()
.Note:
currentSources
will not be updated if the source that is passed in exists
in the currentcurrentSources
cache.Parameters:
Name Type Description srcObj
Tech~SourceObject A string or object source to update our caches to.
Events
-
canplay
-
The media has a readyState of HAVE_FUTURE_DATA or greater.
Type: EventTarget~Event
-
canplaythrough
-
The media has a readyState of HAVE_ENOUGH_DATA or greater. This means that the
entire media file can be played without buffering.Type: EventTarget~Event
-
ended
-
Fired when the end of the media resource is reached (currentTime == duration)
Type: EventTarget~Event
Listeners of This Event:
-
playing
-
The media is no longer blocked from playback, and has started playing.
Type: EventTarget~Event