This file contains 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
webAudioTouchUnlock(context).then(function (unlocked) | |
{ | |
if(unlocked) | |
{ | |
// AudioContext was unlocked from an explicit user action, | |
// sound should start playing now | |
} | |
else | |
{ | |
// There was no need for unlocking, devices other than iOS |
This file contains 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
function webAudioTouchUnlock (context) | |
{ | |
return new Promise(function (resolve, reject) | |
{ | |
if (context.state === 'suspended' && 'ontouchstart' in window) | |
{ | |
var unlock = function() | |
{ | |
context.resume().then(function() | |
{ |
This file contains 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
function webAudioTouchUnlock (context) | |
{ | |
if (context.state === 'suspended' && 'ontouchstart' in window) | |
{ | |
var unlock = function() | |
{ | |
context.resume().then(function() | |
{ | |
document.body.removeEventListener('touchstart', unlock); | |
document.body.removeEventListener('touchend', unlock); |
This file contains 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
if (context.state === 'suspended' && 'ontouchstart' in window) | |
{ | |
var unlock = function() | |
{ | |
context.resume().then(function() | |
{ | |
document.body.removeEventListener('touchstart', unlock); | |
document.body.removeEventListener('touchend', unlock); | |
}); | |
}; |
This file contains 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
if (context.state === 'suspended' && 'ontouchstart' in window) | |
{ | |
var unlock = function() | |
{ | |
context.resume(); | |
}; | |
document.body.addEventListener('touchstart', unlock, false); | |
document.body.addEventListener('touchend', unlock, false); | |
} |
This file contains 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
if (context.state === 'suspended' && 'ontouchstart' in window) | |
{ | |
var unlock = function() | |
{ | |
context.resume(); | |
}; | |
document.body.addEventListener('touchstart', unlock, false); | |
} |
This file contains 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
if (context.state === 'suspended' && 'ontouchstart' in window) | |
{ | |
context.resume(); | |
} |
This file contains 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
if (context.state === 'suspended' && 'ontouchstart' in window) | |
{ | |
// Unlock it | |
} |
This file contains 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
if (context.state === 'suspended') | |
{ | |
// Unlock it | |
} |
This file contains 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
var AudioContext = window.AudioContext || window.webkitAudioContext; | |
var context = new AudioContext(); |