Version: 2.69.0

Visibility.addObserver()

THEOplayer > Visibility > addObserver

Visibility.addObserver() method

Add a visibility observer to monitor the player.

Signature:
addObserver(step: number, callback: VisibilityObserverCallback): VisibilityObserver;

Parameters

ParameterTypeDescription
stepnumberThe step between every threshold. This number is in the range of ]0, 1].
callbackVisibilityObserverCallbackThe callback to be triggered every time a threshold is crossed.
Returns:

VisibilityObserver

A new visibility observer.

Remarks


- 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.