The Device API allows browsers to have more access to the underlying hardware on the host machine and allows it to appear more "native". Mostly this has been aimed at mobile devices and incorporates the very well known Orientation and Motion APIs. There are, however, a great many other Device APIs available, some of which are well supported and some that are only new.
This was a talk presented at Web Directions Code 2014 and explored numerous facets of the Device API, including:
- Sensor APIs
- Web NFC
- Network APIs
- Proximity
- Battery Status
- Vibration
- Ambient light
The presentation is embedded below:
A Device API Safari - WDC 2014
The main aim of this talk was to have a large number of demos in the 20 minute presentation in order to show case what was possible. All the code for these demos is available in the repo.
The demos are embedded below if you'd like to play with them in more detail noting that support can be a bit hit and miss. Firefox is pretty much guaranteed.
Proximity
Support: all mobile devices with a proximity sensor
Battery
Support: All modern browsers except IE (any)
Vibration
Support: Most devices that have vibration motor in them
Application in HTML games:
Application in form error reporting:
Ambient light
Support: Firefox on desktop and most mobile devices
Application in contrast modification:
Ambient light for contrast modification
Application in silliness: