The Visibility API provides developers a way to observe how much of the player is visible.
visibility object provides the following properties:
|visible||boolean||Indicates whether or not the ratio of visible pixels of the player exceeds the
|ratio||number||Indicates the ratio of pixels of the player that are within the viewport.|
|visibleThreshold||number||Gets or sets the threshold that the ratio must exceed for the player to be visible.|
visibility object provides the following methods:
|addObserver||step : number, callback : function||
Adds an observer to monitor the visibility of the player, and returns the created VisibilityObserver.
The callback is triggered every time the ratio of visible pixels crosses a threshold, and receives the ratio of visible pixels as first argument.
The list of thresholds is evenly distributed between 0 and 1, with the distance between every two consecutive thresholds determined by the given step.
|removeObserver||observer : VisibilityObserver||Removes a previously created visibility observer.|
VisibilityObserver API enables you to access the thresholds and ratio of a visibility observer.
VisibilityObserver object provides the following properties:
|ratio||number||The ratio of pixels of the player that are within the viewport.|
|thresholds||number||The list of thresholds which are monitored by this observer.|