Skip to content

Commit

Permalink
Merge pull request #386 from d-i-t-a/bugfix/media-overlay-pause
Browse files Browse the repository at this point in the history
media overlay pause - audio element could be undefined
  • Loading branch information
aferditamuriqi authored Sep 20, 2022
2 parents 48474ee + e165394 commit 9257391
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@d-i-t-a/reader",
"version": "2.1.0-beta.10",
"version": "2.1.0-beta.11",
"description": "A viewer application for EPUB files.",
"repository": "https://github.com/d-i-t-a/R2D2BC",
"license": "Apache-2.0",
Expand Down
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 9257391

Please sign in to comment.