From 22d6c99f44427658b5ef34efc883c6c27b2c8370 Mon Sep 17 00:00:00 2001 From: Patrick Farwick <9168045+MinecraftPlaye@users.noreply.github.com> Date: Wed, 19 Jan 2022 21:26:48 +0000 Subject: [PATCH 1/2] Update the resume button after stopping --- src/plugins/bookPlayer/plugin.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/plugins/bookPlayer/plugin.js b/src/plugins/bookPlayer/plugin.js index ac91cf6aa5..f6d4b7b4ba 100644 --- a/src/plugins/bookPlayer/plugin.js +++ b/src/plugins/bookPlayer/plugin.js @@ -44,6 +44,12 @@ export class BookPlayer { stop() { this.unbindEvents(); + const stopInfo = { + src: this.item + }; + + Events.trigger(this, 'stopped', [stopInfo]); + const elem = this.mediaElement; const tocElement = this.tocElement; const rendition = this.rendition; @@ -67,6 +73,10 @@ export class BookPlayer { this.cancellationToken = true; } + destroy() { + // Nothing to do here + } + currentItem() { return this.item; } @@ -149,8 +159,8 @@ export class BookPlayer { bindMediaElementEvents() { const elem = this.mediaElement; - elem.addEventListener('close', this.onDialogClosed, {once: true}); - elem.querySelector('#btnBookplayerExit').addEventListener('click', this.onDialogClosed, {once: true}); + elem.addEventListener('close', this.onDialogClosed, { once: true }); + elem.querySelector('#btnBookplayerExit').addEventListener('click', this.onDialogClosed, { once: true }); elem.querySelector('#btnBookplayerToc').addEventListener('click', this.openTableOfContents); elem.querySelector('#btnBookplayerFullscreen').addEventListener('click', this.toggleFullscreen); elem.querySelector('#btnBookplayerPrev')?.addEventListener('click', this.previous); @@ -250,6 +260,7 @@ export class BookPlayer { this.streamInfo = { started: true, ended: false, + item: this.item, mediaSource: { Id: item.Id } @@ -263,9 +274,9 @@ export class BookPlayer { } return new Promise((resolve, reject) => { - import('epubjs').then(({default: epubjs}) => { + import('epubjs').then(({ default: epubjs }) => { const downloadHref = apiClient.getItemDownloadUrl(item.Id); - const book = epubjs(downloadHref, {openAs: 'epub'}); + const book = epubjs(downloadHref, { openAs: 'epub' }); // We need to calculate the height of the window beforehand because using 100% is not accurate when the dialog is opening. // In addition we don't render to the full height so that we have space for the top buttons. From d4907ac522065638684bc7224be83f573784d23a Mon Sep 17 00:00:00 2001 From: Patrick Farwick <9168045+MinecraftPlaye@users.noreply.github.com> Date: Wed, 19 Jan 2022 23:04:57 +0000 Subject: [PATCH 2/2] Remove the timer from progress saving for epubs --- src/plugins/bookPlayer/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/bookPlayer/plugin.js b/src/plugins/bookPlayer/plugin.js index f6d4b7b4ba..6d85cb25df 100644 --- a/src/plugins/bookPlayer/plugin.js +++ b/src/plugins/bookPlayer/plugin.js @@ -312,7 +312,7 @@ export class BookPlayer { epubElem.style.display = 'block'; rendition.on('relocated', (locations) => { this.progress = book.locations.percentageFromCfi(locations.start.cfi); - Events.trigger(this, 'timeupdate'); + Events.trigger(this, 'pause'); }); loading.hide();