Skip to content

Commit

Permalink
audio element could be undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
aferditamuriqi committed Sep 20, 2022
1 parent a8da6cd commit e165394
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/modules/mediaoverlays/MediaOverlayModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ export class MediaOverlayModule implements ReaderModule {
);
} else {
if (this.audioElement) {
await this.audioElement.pause();
await this.audioElement?.pause();
}
if (this.currentLinks.length > 1 && this.currentLinkIndex === 0) {
this.currentLinkIndex++;
await this.playLink();
} else {
if (this.settings.autoTurn && this.settings.playing) {
this.audioElement.pause();
this.audioElement?.pause();
this.delegate.nextResource();
} else {
this.stopReadAloud();
Expand Down Expand Up @@ -241,7 +241,7 @@ export class MediaOverlayModule implements ReaderModule {
pauseReadAloud() {
if (this.delegate.rights.enableMediaOverlays) {
this.settings.playing = false;
this.audioElement.pause();
this.audioElement?.pause();
if (this.play) this.play.style.removeProperty("display");
if (this.pause) this.pause.style.display = "none";
}
Expand Down Expand Up @@ -377,9 +377,9 @@ export class MediaOverlayModule implements ReaderModule {
this.currentLinkIndex++;
this.playLink();
} else {
this.audioElement.pause();
this.audioElement?.pause();
if (this.settings.autoTurn && this.settings.playing) {
this.audioElement.pause();
this.audioElement?.pause();
this.delegate.nextResource();
} else {
this.stopReadAloud();
Expand Down Expand Up @@ -425,9 +425,9 @@ export class MediaOverlayModule implements ReaderModule {
this.currentLinkIndex++;
this.playLink();
} else {
this.audioElement.pause();
this.audioElement?.pause();
if (this.settings.autoTurn && this.settings.playing) {
this.audioElement.pause();
this.audioElement?.pause();
this.delegate.nextResource();
} else {
this.stopReadAloud();
Expand All @@ -449,7 +449,7 @@ export class MediaOverlayModule implements ReaderModule {
this.mediaOverlayHighlight(undefined);

if (this.audioElement) {
this.audioElement.pause();
this.audioElement?.pause();
}
}
findNextTextAudioPair(
Expand Down Expand Up @@ -645,7 +645,7 @@ export class MediaOverlayModule implements ReaderModule {
) as HTMLAudioElement;

if (this.audioElement) {
this.audioElement.pause();
this.audioElement?.pause();
this.audioElement.setAttribute("src", "");
if (this.audioElement.parentNode) {
this.audioElement.parentNode.removeChild(this.audioElement);
Expand Down Expand Up @@ -699,7 +699,7 @@ export class MediaOverlayModule implements ReaderModule {
await this.playLink();
} else {
if (this.settings.autoTurn && this.settings.playing) {
this.audioElement.pause();
this.audioElement?.pause();
this.delegate.nextResource();
} else {
this.stopReadAloud();
Expand Down

0 comments on commit e165394

Please sign in to comment.