Fall back to webkitAudioContext

This commit is contained in:
Vanilagy
2025-08-11 01:51:20 +02:00
parent 11c15c2392
commit 80c6fa3201
2 changed files with 7 additions and 0 deletions
+3
View File
@@ -132,6 +132,9 @@ const initMediaPlayer = async (file: File) => {
warningElement.textContent = problemMessage;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
const AudioContext = window.AudioContext || (window as any).webkitAudioContext;
// We must create the audio context with the matching sample rate for correct acoustic results
// (especially for low-sample rate files)
audioContext = new AudioContext({ sampleRate: audioTrack?.sampleRate });
+4
View File
@@ -1446,6 +1446,10 @@ export class MediaStreamAudioTrackSource extends AudioSource {
});
} else {
// Let's fall back to an AudioContext approach
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
const AudioContext = window.AudioContext || (window as any).webkitAudioContext;
this._audioContext = new AudioContext({ sampleRate: this._track.getSettings().sampleRate });
const sourceNode = this._audioContext.createMediaStreamSource(new MediaStream([this._track]));
this._scriptProcessorNode = this._audioContext.createScriptProcessor(4096);