Combine preloadBellSound and syncBellSound into the same function
This commit is contained in:
+7
-11
@@ -485,8 +485,8 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
this.viewport.syncScrollArea();
|
this.viewport.syncScrollArea();
|
||||||
break;
|
break;
|
||||||
case 'tabStopWidth': this.setupStops(); break;
|
case 'tabStopWidth': this.setupStops(); break;
|
||||||
case 'bellSound': this.syncBellSound(); break;
|
case 'bellSound':
|
||||||
case 'bellStyle': this.preloadBellSound(); break;
|
case 'bellStyle': this.syncBellSound(); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,7 +695,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
this.viewportElement.appendChild(this.viewportScrollArea);
|
this.viewportElement.appendChild(this.viewportScrollArea);
|
||||||
|
|
||||||
// preload audio
|
// preload audio
|
||||||
this.preloadBellSound();
|
this.syncBellSound();
|
||||||
|
|
||||||
// Create the selection container.
|
// Create the selection container.
|
||||||
this.selectionContainer = document.createElement('div');
|
this.selectionContainer = document.createElement('div');
|
||||||
@@ -2294,8 +2294,10 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
this.options.bellStyle === 'both';
|
this.options.bellStyle === 'both';
|
||||||
}
|
}
|
||||||
|
|
||||||
private preloadBellSound(): void {
|
private syncBellSound(): void {
|
||||||
if (this.soundBell()) {
|
if (this.soundBell() && this.bellAudioElement) {
|
||||||
|
this.bellAudioElement.setAttribute('src', this.options.bellSound);
|
||||||
|
} else if (this.soundBell()) {
|
||||||
this.bellAudioElement = document.createElement('audio');
|
this.bellAudioElement = document.createElement('audio');
|
||||||
this.bellAudioElement.setAttribute('preload', 'auto');
|
this.bellAudioElement.setAttribute('preload', 'auto');
|
||||||
this.bellAudioElement.setAttribute('src', this.options.bellSound);
|
this.bellAudioElement.setAttribute('src', this.options.bellSound);
|
||||||
@@ -2304,12 +2306,6 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
this.helperContainer.removeChild(this.bellAudioElement);
|
this.helperContainer.removeChild(this.bellAudioElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private syncBellSound(): void {
|
|
||||||
if (this.soundBell() && this.bellAudioElement) {
|
|
||||||
this.bellAudioElement.setAttribute('src', this.options.bellSound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user