Add check audiocontext support
This commit is contained in:
parent
1a1ee3467d
commit
60fbfe55aa
1 changed files with 11 additions and 8 deletions
|
@ -120,7 +120,7 @@ class HtmlAudioPlayer {
|
||||||
}
|
}
|
||||||
console.debug('gain:' + self.gainNode.gain.value);
|
console.debug('gain:' + self.gainNode.gain.value);
|
||||||
}).catch((err)=> {
|
}).catch((err)=> {
|
||||||
console.error('[UserSettings] failed to load userSettings', err);
|
console.error('Failed to add/change gainNode', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Convert to seconds
|
// Convert to seconds
|
||||||
|
@ -263,8 +263,8 @@ class HtmlAudioPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addGainElement(elem) {
|
function addGainElement(elem) {
|
||||||
|
try {
|
||||||
const audioCtx = new AudioContext(); /* eslint-disable-line compat/compat */
|
const audioCtx = new AudioContext(); /* eslint-disable-line compat/compat */
|
||||||
|
|
||||||
const source = audioCtx.createMediaElementSource(elem);
|
const source = audioCtx.createMediaElementSource(elem);
|
||||||
|
|
||||||
const gainNode = audioCtx.createGain();
|
const gainNode = audioCtx.createGain();
|
||||||
|
@ -273,6 +273,9 @@ class HtmlAudioPlayer {
|
||||||
gainNode.connect(audioCtx.destination);
|
gainNode.connect(audioCtx.destination);
|
||||||
|
|
||||||
self.gainNode = gainNode;
|
self.gainNode = gainNode;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Web Audio API is not supported in this browser', e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEnded() {
|
function onEnded() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue