Skip to content

Instantly share code, notes, and snippets.

@rectalogic
Last active December 11, 2015 21:08
Show Gist options
  • Save rectalogic/4659889 to your computer and use it in GitHub Desktop.
Save rectalogic/4659889 to your computer and use it in GitHub Desktop.
<html>
<head>
<script type="text/javascript">
function init() {
var video = document.getElementById("video");
video.addEventListener('pause', stopLogging, false);
video.addEventListener('playing', startLogging, false);
console.log("READY");
}
function stopLogging() {
window.removeEventListener('devicemotion', logMotion, false);
console.log("STOP");
}
function startLogging() {
console.log("START");
window.addEventListener('devicemotion', logMotion, false);
}
function logMotion(event) {
console.log(event.accelerationIncludingGravity.x);
}
</script>
</head>
<body onload="init();">
<video id="video" width="848" height="352" autoplay src="http://movies.apple.com/media/us/html5/showcase/2011/demos/apple-html5-demo-tron-us_848x352.m4v"></video>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment