diff --git a/src/Terminal.ts b/src/Terminal.ts index 98780f5c..332642b1 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -485,7 +485,8 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT this.viewport.syncScrollArea(); break; case 'tabStopWidth': this.setupStops(); break; - case 'bellStyle': this.preloadBellSound(); break; + case 'bellSound': + case 'bellStyle': this.syncBellSound(); break; } } @@ -694,7 +695,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT this.viewportElement.appendChild(this.viewportScrollArea); // preload audio - this.preloadBellSound(); + this.syncBellSound(); // Create the selection container. this.selectionContainer = document.createElement('div'); @@ -2293,8 +2294,10 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT this.options.bellStyle === 'both'; } - private preloadBellSound(): void { - if (this.soundBell()) { + private syncBellSound(): void { + if (this.soundBell() && this.bellAudioElement) { + this.bellAudioElement.setAttribute('src', this.options.bellSound); + } else if (this.soundBell()) { this.bellAudioElement = document.createElement('audio'); this.bellAudioElement.setAttribute('preload', 'auto'); this.bellAudioElement.setAttribute('src', this.options.bellSound); diff --git a/src/Types.ts b/src/Types.ts index c287030d..c1cf9e63 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -31,6 +31,7 @@ export type BooleanOption = export type StringOption = 'cursorStyle' | 'bellStyle' | + 'bellSound' | 'termName'; export type StringArrayOption = 'colors'; export type NumberOption =