Skip to content

Commit

Permalink
Merge pull request #906 from npezza93/sync-bell-sound-on-change
Browse files Browse the repository at this point in the history
When bellSound changes, update the bellAudioElements src
  • Loading branch information
Tyriar authored Aug 19, 2017
2 parents 9ab17de + f983e4e commit f251047
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type BooleanOption =
export type StringOption =
'cursorStyle' |
'bellStyle' |
'bellSound' |
'termName';
export type StringArrayOption = 'colors';
export type NumberOption =
Expand Down

0 comments on commit f251047

Please sign in to comment.