playing with sensors in open web apps

53
T3LAB via Sario Bassanelli, 9/11, > Bologna Firefox OS WORKSHOP Wednesday 17th September 2014 > 10:00 - 18:00 Register now! www.t3lab.it/eventi WORKSHOP Agenda > Speakers > 10:00 Welcome! 10:15 Conference Time Inside Firefox OS Developing on Firefox OS for newbie Playing with Sensors in Open Web Apps 14:00 Coding Time organized by sponsored by Francesco Iovine (Mozillian) Daniele Scasciafratte (Mozillian) Luca Greco (Mozillian)

Upload: francesco-iovine

Post on 19-Jun-2015

253 views

Category:

Software


6 download

DESCRIPTION

One of the main weaknesses of web applications is that browsers can access a limited set of device services, such as geolocation, device orientation etc. In this talk I will explore how the W3C and browser vendors are working together to enable the development of Open Web Apps that can access device hardware and sensors through Javascript. I will also show the code of example applications you can try directly on Firefox for your mobile devices.

TRANSCRIPT

Page 1: Playing with sensors in Open Web Apps

T3LAB via Sario Bassanelli, 9/11, > Bologna

Firefox OS WORKSHOPWednesday 17th September 2014 > 10:00 - 18:00

Register now!

www.t3lab.it/eventi

W O R K S H O P

Agenda >

Speakers >

10:00 Welcome!

10:15 Conference Time

Inside Firefox OS

Developing on Firefox OS for newbie

Playing with Sensors in Open Web Apps

14:00 Coding Time

organized by sponsored by

Francesco Iovine(Mozillian)

Daniele Scasciafratte(Mozillian)

Luca Greco(Mozillian)

Page 2: Playing with sensors in Open Web Apps

Playing with sensorsin Open Web Apps

Francesco Iovine@franciov

Bologna, 17 Sep 2014

Firefox OS workshop

Page 4: Playing with sensors in Open Web Apps

I live in Rome

Page 5: Playing with sensors in Open Web Apps

This was my first presentation ...

Page 6: Playing with sensors in Open Web Apps

... and this my first mobile device

Page 7: Playing with sensors in Open Web Apps

I like attending tech conferences across Europe ...

Page 8: Playing with sensors in Open Web Apps

... and playing table football

Page 9: Playing with sensors in Open Web Apps

Network

Touch

Geolocation

Motion

Battery

Proximity

Media Capture

Media Recording

Ambient

Contacts

Calendar

Vibration

WebAPI / Device APIs

Page 10: Playing with sensors in Open Web Apps

TOUCH

Page 11: Playing with sensors in Open Web Apps

touchstart

touchmove

touchend

touchcancel

Touch Events

Page 12: Playing with sensors in Open Web Apps

Geolocation

Page 13: Playing with sensors in Open Web Apps

navigator.geolocation.getCurrentPosition(showMap)

function showMap(position) {

var latitude = position.coords.latitude;

var longitude = position.coords.longitude;

// ...

}

Geolocation API

Page 14: Playing with sensors in Open Web Apps

http://goo.gl/FVhr5L

Page 17: Playing with sensors in Open Web Apps

CONTACTS

Page 18: Playing with sensors in Open Web Apps

window.navigator.mozContacts

window.navigator.mozContacts.getAll(options)

window.navigator.mozContacts.find(filter)

window.navigator.mozContacts.save(mozContact)

...

mozContacts

Page 19: Playing with sensors in Open Web Apps

{

"name": "Geo",

"description": "Geolocation web application",

"type": "privileged",

"launch_path": "/index.html",

"permissions": {

"contacts": {

"description": "Required for plotting contacts on the map",

"access": "readwrite"

}

}

}

manifest.webapp

Page 20: Playing with sensors in Open Web Apps
Page 23: Playing with sensors in Open Web Apps

MOTION

Page 24: Playing with sensors in Open Web Apps

window.onorientationchange

window.ondeviceorientation

window.ondevicemotion

window.oncompassneedscalibration

DeviceOrientation Events

Page 25: Playing with sensors in Open Web Apps

http://goo.gl/NUfKQi

Page 28: Playing with sensors in Open Web Apps

VIBRATION

Page 29: Playing with sensors in Open Web Apps

navigator.vibrate(1000);// or alternativelynavigator.vibrate([1000]);

navigator.vibrate([50, 100, 150]);

navigator.vibrate(0);// or alternativelynavigator.vibrate([]);

Vibration API

Page 30: Playing with sensors in Open Web Apps

BATTERY

Page 31: Playing with sensors in Open Web Apps

navigator.battery.charging // true or falsenavigator.battery.level // from 0 to 1.0navigator.battery.chargingTime // seconds navigator.battery.dischargingTime // seconds

navigator.battery.onchargingchangenavigator.battery.onlevelchangenavigator.battery.ondischargingtimechange

Battery Status API

Page 32: Playing with sensors in Open Web Apps

http://goo.gl/87QanF

Page 35: Playing with sensors in Open Web Apps

PROXIMITY

Page 36: Playing with sensors in Open Web Apps

window.ondeviceproximity = function(event) { event.value // current device proximity (cm) event.max // maximum sensing distance (cm) event.min // minimum sensing distance (cm)});

window.onuserproximity = function(event) { event.near // current user proximity state});

Proximity Events

Page 37: Playing with sensors in Open Web Apps

http://goo.gl/87QanF

Page 40: Playing with sensors in Open Web Apps

AMBIENT

Page 41: Playing with sensors in Open Web Apps

window.ondevicelight = function(event) {

event.value // lux units

});

Ambient Light Events

window.onlightlevel = function(event) {

event.value // “dim”, “normal” or “bright”

});

Page 42: Playing with sensors in Open Web Apps

http://goo.gl/Dzc59h

Page 43: Playing with sensors in Open Web Apps

http://goo.gl/Dzc59h

Page 46: Playing with sensors in Open Web Apps

Network

Touch

Geolocation

Motion

Battery

Proximity

Media Capture

Media Recording

Ambient

Contacts

Calendar

Vibration

WebAPI / Device APIs

Page 47: Playing with sensors in Open Web Apps

References

Page 48: Playing with sensors in Open Web Apps

https://developer.mozilla.org/en-US/docs/WebAPI

Page 49: Playing with sensors in Open Web Apps

www.w3.org/2009/dap/www.w3.org/2009/dap/wiki/ImplementationStatus

Page 51: Playing with sensors in Open Web Apps
Page 52: Playing with sensors in Open Web Apps

Photoshttps://www.flickr.com/photos/phototomcat/9658315475/thanks to Markus Leutwyler (markusleutwyler.com)http://instagram.com/ar_krayon (football table)

http://www.flickr.com/photos/kevandotorg/5837174879 (network)http://www.flickr.com/photos/htakashi/9754012931 (battery)http://www.flickr.com/photos/linkey/3400532620 (touch)http://www.flickr.com/photos/26733538@N08/3029266745 (motion)http://www.flickr.com/photos/petereed/3256701422 (geolocation)http://www.flickr.com/photos/ederfortunato/7998206930 (camera)http://www.flickr.com/photos/mattimattila/3299901660 (recording)http://www.flickr.com/photos/shuttercat7/418349082 (proximity)http://www.flickr.com/photos/pagedooley/7899921242 (ambient)http://www.flickr.com/photos/andreanix/2577986521 (contacts)http://www.flickr.com/photos/oschene/8334277572 (calendar)

http://www.flickr.com/photos/vividbreeze/480057824 (thankyou, questions?)