Created
March 29, 2016 14:19
-
-
Save naosim/adb02f3c47edc02b7314 to your computer and use it in GitHub Desktop.
[FireFox]部屋の灯りが消えたら自動でGet Wild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FireFoxにある照度センサーのAPIを使ってるのでFireFox以外では動きません。
このhtmlファイルと同列にgetwildの音源(getwild.mp4)を置いて起動してください。