diff --git a/morseplayer.js b/morseplayer.js index fac4028..68d804b 100644 --- a/morseplayer.js +++ b/morseplayer.js @@ -1,7 +1,19 @@ -// Firefox +// Polyfill if (typeof AudioParam.prototype.cancelAndHoldAtTime !== 'function') { - AudioParam.prototype.cancelAndHoldAtTime = AudioParam.prototype.cancelScheduledValues; + if (typeof AudioParam.prototype.cancelValuesAndHoldAtTime !== 'function') { + // Firefox + AudioParam.prototype.cancelAndHoldAtTime = function (cancelTime) { + const audioParam = this; + const valueAtCancelTime = audioParam.getValueAtTime ? audioParam.getValueAtTime(cancelTime) : audioParam.value; + + audioParam.cancelScheduledValues(cancelTime); + audioParam.setValueAtTime(valueAtCancelTime, cancelTime); + }; + } else { + // Chrome <57 + AudioParam.prototype.cancelAndHoldAtTime = AudioParam.prototype.cancelValuesAndHoldAtTime; + } } class CWPlayer {