Skip to content

Commit

Permalink
amélioration polyfill Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
spasutto authored Jan 31, 2025
1 parent 9f4ac9a commit 265fa75
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions morseplayer.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 265fa75

Please sign in to comment.