Skip to content

Instantly share code, notes, and snippets.

@naosim
Created March 29, 2016 14:19
Show Gist options
  • Save naosim/adb02f3c47edc02b7314 to your computer and use it in GitHub Desktop.
Save naosim/adb02f3c47edc02b7314 to your computer and use it in GitHub Desktop.
[FireFox]部屋の灯りが消えたら自動でGet Wild
<!DOCTYPE html>
<audio id="audio" src="getwild.mp4" controls>
<script>
var isPlaying = false;
window.addEventListener('devicelight', function(event) {
console.log(event.value + 'lux');
if(isPlaying) {
return;
}
if(event.value < 20) {// しきい値適当
isPlaying = true;
document.querySelector('#audio').play();
}
});
</script>
@naosim
Copy link
Author

naosim commented Mar 29, 2016

FireFoxにある照度センサーのAPIを使ってるのでFireFox以外では動きません。
このhtmlファイルと同列にgetwildの音源(getwild.mp4)を置いて起動してください。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment