This commit is contained in:
Jordan Eldredge 2018-02-11 13:55:55 -08:00
parent d8980893c0
commit 512f123cfa

View file

@ -5,6 +5,21 @@ import ElementSource from "./elementSource";
export default class Media {
constructor() {
this._context = new (window.AudioContext || window.webkitAudioContext)();
// Fix for iOS: https://gist.github.com/laziel/7aefabe99ee57b16081c
// Via: https://stackoverflow.com/a/43395068/1263117
if (this._context.state === "suspended") {
const resume = () => {
this._context.resume();
setTimeout(() => {
if (this._context.state === "running") {
document.body.removeEventListener("touchend", resume, false);
}
}, 0);
};
document.body.addEventListener("touchend", resume, false);
}
this._callbacks = {
waiting: function() {},
stopWaiting: function() {},