Fixes console error when setting null values as volume for the quiz sound

parent 89563042
...@@ -176,7 +176,7 @@ export class SoundManagerComponent implements OnInit, OnDestroy { ...@@ -176,7 +176,7 @@ export class SoundManagerComponent implements OnInit, OnDestroy {
if (isPlatformBrowser(this.platformId)) { if (isPlatformBrowser(this.platformId)) {
const audioElements = document.getElementsByTagName('audio'); const audioElements = document.getElementsByTagName('audio');
for (let i = 0; i < audioElements.length; i++) { for (let i = 0; i < audioElements.length; i++) {
(<HTMLAudioElement>audioElements.item(i)).volume = (this.config.volumeConfig[target] || 60) / 100; (<HTMLAudioElement>audioElements.item(i)).volume = (parseInt(String(this.config.volumeConfig[target]), 10) || 60) / 100;
} }
} }
} }
......
...@@ -40,7 +40,7 @@ export class AudioPlayerComponent implements AfterViewInit, OnDestroy { ...@@ -40,7 +40,7 @@ export class AudioPlayerComponent implements AfterViewInit, OnDestroy {
this._original_volume = value; this._original_volume = value;
this._volume = this._original_volume; this._volume = this._original_volume;
if (this.audioElement) { if (this.audioElement) {
this.audioElement.volume = parseInt(this._volume, 10) / 100; this.audioElement.volume = (parseInt(this._volume, 10) || 0) / 100;
} }
} }
...@@ -81,7 +81,7 @@ export class AudioPlayerComponent implements AfterViewInit, OnDestroy { ...@@ -81,7 +81,7 @@ export class AudioPlayerComponent implements AfterViewInit, OnDestroy {
set volume(value: string) { set volume(value: string) {
this._volume = value; this._volume = value;
this.volumeChange.emit(this.volume); this.volumeChange.emit(this.volume);
this.audioElement.volume = parseInt(this.volume, 10) / 100; this.audioElement.volume = (parseInt(this._volume, 10) || 0) / 100;
} }
private _isPlaying = false; private _isPlaying = false;
...@@ -123,7 +123,7 @@ export class AudioPlayerComponent implements AfterViewInit, OnDestroy { ...@@ -123,7 +123,7 @@ export class AudioPlayerComponent implements AfterViewInit, OnDestroy {
} }
public ngAfterViewInit(): void { public ngAfterViewInit(): void {
this.audioElement.volume = parseInt(this._volume, 10) / 100; this.audioElement.volume = (parseInt(this._volume, 10) || 0) / 100;
} }
public ngOnDestroy(): void { public ngOnDestroy(): void {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment