This repository has been archived on 2020-04-21. You can view files and clone it, but cannot push or open issues or pull requests.
ludum-dare-46/docs/assets/js/sounds/permissionhandler.js

22 lines
459 B
JavaScript

/**
* This file just exists to keep track of weather the user has interacted with the
* webpage. Most browsers will block autoplay if no interaction has been made.
*/
// Tracker for permission unlock
let _audioPermUnlock = false;
/**
* Call this when the user interacts with the page
*/
function unlockAudioPermission() {
_audioPermUnlock = true;
}
/**
* Check if autoplay is enabled
*/
function canPlayAudio() {
return _audioPermUnlock;
}