Constructor
new SRGAnalytics(player, optionsopt)
Creates an instance of SRGAnalytics.
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
player | Player | The player instance | |||||||||||||||||||||||||||
options | SRGAnalyticsOptions | <optional> | {} | Configuration options Properties
|
- Source
Methods
beforeunload()
Sent when the window, the document and its resources are about to be unloaded.
- Source
clearTimers()
Clear timers used to send uptime and heartbeat.
- Source
currentTime() → {Number}
Get the tracked current time in seconds.
- Source
current time in seconds
- Type:
- Number
debug() → {Boolean|undefined}
Get or set debug mode.
- Source
- Type:
- Boolean |
undefined
destroy()
Destroy all properties and setIntervals to avoid mixing media sessions.
- Source
dispose()
Dispose all listeners used to send analytics data to TagCommander.
Calls beforeunload
to send a notify stop. Clear intervals and timeouts.
Used events
- beforeunload
- emptied
- ended
- loadstart
- loadeddata
- play
- pause
- timeupdate
- Source
emptied()
Sent before a new media is loading.
- Destroy all properties.
- Send a notify stop if the media is not ended and new media is about to be loaded.
- Source
ended()
Sent when playback completes.
- Source
flush()
Flush the queued events when tc event script is loaded.
- Source
getCurrentAudioTrack() → {String}
Get the language of the current audio track.
- Source
empty string or uppercase language.
- Type:
- String
getCurrentTextTrack() → {String}
Get the language of the current text track.
- Source
empty string or uppercase language.
- Type:
- String
getDvrWindowPosition() → {Number}
Get the position inside the dvr window where the 0 represents the live edge
- Source
0 or the position in milliseconds
- Type:
- Number
getDvrWindowSize() → {Number}
Get the size of the live DVR window in milliseconds.
- Source
DVR window size in milliseconds
- Type:
- Number
getElapsedPlaybackTime() → {Number}
Get the elapsed playback time in seconds.
- Source
elapsed time in seconds
- Type:
- Number
getElapsedPlayingTime() → {Number}
Get the elapsed playing time in seconds.
- Source
elapsed time in seconds
- Type:
- Number
getEventLabels(eventName) → {Object}
Set all event labels to be sent to TagCommander. The event labels are updated whenever a new event occurs.
Name | Type | Description |
---|---|---|
eventName | String | init | play | stop | pos | pause | seek | uptime | eof |
- Source
JSON to be sent to TagCommander
- Type:
- Object
getInternalLabels()
Set all internal labels to be sent to TagCommander. Internal labels are assigned once at initialisation time.
- Source
heartBeat()
The action pos should be sent regularly every 30 seconds. It is used for tracking the viewed chapters of a video and the last position of the video, in case the user ends the video by closing the browser tab/window.
- pos should be sent when the media player is in "play mode".
- once the video is paused or stopped, the timer for sending these actions must be stopped.
- Source
initCallbacks()
Initialize callbacks used to send analytics data to TagCommander.
Used events
- beforeunload
- emptied
- ended
- loadstart
- loadeddata
- play
- pause
- ratechange
- seeking
- timeupdate
- waiting
- Source
initListeners()
Initialize all listeners used to send analytics data to TagCommander.
Used events
- beforeunload
- dispose
- emptied
- ended
- loadstart
- loadeddata
- play
- pause
- timeupdate
- waiting
- Source
initScript()
Initialize TagCommander script dynamically and add it to the DOM
- Source
isAudioDescriptionEnabled() → {Boolean}
Check if the audio description track is enabled.
- Source
true if enabled false otherwise.
- Type:
- Boolean
isAudioTrackEnabled() → {Boolean}
Check if the audio track is enabled.
- Source
true if enabled false otherwise.
- Type:
- Boolean
isMediaDvr() → {Boolean}
Check if the media is a live with DVR.
- Source
true if it DVR false otherwise.
- Type:
- Boolean
isMediaLive() → {Boolean}
Check if the media is a live.
- Source
true if live false otherwise.
- Type:
- Boolean
isMediaOnDemand() → {Boolean}
Check if the media is an on demand.
- Source
true if on demand false otherwise.
- Type:
- Boolean
isTextTrackEnabled() → {Boolean}
Check if the text track is enabled.
- Source
true if enabled false otherwise.
- Type:
- Boolean
isTrackerDisabled() → {Boolean}
Check if the tracker is disabled.
- Source
true if disabled false otherwise.
- Type:
- Boolean
loadeddata()
The first frame of the media has finished loading.
- Source
loadstart()
Sent when loading of the media begins.
- Source
log(eventName, eventMetadata, severity)
Event logger that prints the current event, event labels and internal labels in the browser's console.
Name | Type | Default | Description |
---|---|---|---|
eventName | String | init | play | stop | pos | pause | seek | uptime | eof | |
eventMetadata | Object | event metadata object | |
severity | String | log | log | warn | error |
- Source
notify(eventName)
Notify TagCommander all event and internal labels. If tc script is not available it queues all pending events.
Name | Type | Description |
---|---|---|
eventName | String | init | play | stop | pos | pause | seek | uptime | eof |
- Source
pause()
Sent when the playback state is changed to paused (paused property is true). Pause event is sent if :
- The player is not scrubbing
- The stream is not a live only
- The current time is strictly inferior to the duration
- Source
play()
Sent when the playback state is no longer paused, as a result of the play method, or the autoplay attribute.
- Source
rateChange()
Sent to ComScore when the playback rate changes.
- Source
reloadTagCommanderContainer()
Reload the tagCommander container and set all ComScore labels
- Source
seeking()
Sent when the current time is modified by the player's currentTime API.
- Source
timeShifted() → {String}
Gets the number of seconds that separate from the live edge that is represented by 0.
- Source
- Type:
- String
timeUpdate()
Track current time updates delayed by a tick.
- Source
updateSrcMediaData()
Update the src media data.
- Source
uptime()
Calculate the uptime when playing a live stream with or without DVR
Rules:
- Send the first uptime after 30 seconds
- Send uptime each 60 seconds after the 30 seconds
- Uptime is sent only when playing
- Source
waiting()
ComScore: It's expected notifyBufferStart() to be called when the player starts buffering and a call to notifyBufferStop() when content resumes after buffering.
- Source
- See
- Item 2: https://jira.srg.beecollaboration.com/browse/PLAY-2628 After the issue PLAYRTS-321
- Fix: https://jira.srg.beecollaboration.com/browse/PLAYRTS-321?focusedCommentId=201023&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-201023
- Fix: https://jira.srg.beecollaboration.com/browse/PLAYRTS-3065
(static) now() → {Number}
Return the current timestamp in seconds.
- Source
Timestamp in seconds
- Type:
- Number