The Ambient Light API allows web applications to access the light intensity level measured by the device's light sensor.
The first approach to supporting light intensity sensor on the web - as a standalone API - was implemented in Firefox. Since then the specification was rewritten to make use of the new Generic Sensors API, but no vendor implemented that spec as of September 2016.
The old, standalone API
- An event fired when the device's light sensor measured value has changed, containing the light intensity expressed in lux.
The new, generic API
sensor = new AmbientLightSensor()
- Creates an object serving as an accessor to the light intensity sensor readings.
- An event fired when the light intensity has changed, with
event.reading.illuminanceproperty containing the light intensity expressed in lux.
- Starts listening for the sensor readings.