Merge pull request #3034 from MinecraftPlaye/feature-comicposition

Save the progress when reading a Comic Book Archive
This commit is contained in:
Bill Thornton 2021-10-06 23:20:29 -04:00 committed by GitHub
commit bf736771ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 5 deletions

View file

@ -49,6 +49,7 @@
- [Ömer Erdinç Yağmurlu](https://github.com/omeryagmurlu)
- [Keegan Dahm](https://github.com/keegandahm)
- [GodTamIt](https://github.com/GodTamIt)
- [MinecraftPlaye](https://github.com/MinecraftPlaye)
# Emby Contributors

View file

@ -24,7 +24,8 @@ export class ComicsPlayer {
}
play(options) {
this.progress = 0;
this.currentPage = 0;
this.pageCount = 0;
const elem = this.createMediaElement();
return this.setCurrentSrc(elem, options);
@ -33,6 +34,12 @@ export class ComicsPlayer {
stop() {
this.unbindEvents();
const stopInfo = {
src: this.item
};
Events.trigger(this, 'stopped', [stopInfo]);
this.archiveSource?.release();
const elem = this.mediaElement;
@ -44,6 +51,38 @@ export class ComicsPlayer {
loading.hide();
}
destroy() {
// Nothing to do here
}
currentTime() {
return this.currentPage;
}
duration() {
return this.pageCount;
}
currentItem() {
return this.item;
}
volume() {
return 100;
}
isMuted() {
return false;
}
paused() {
return false;
}
seekable() {
return true;
}
onDialogClosed() {
this.stop();
}
@ -118,7 +157,15 @@ export class ComicsPlayer {
setCurrentSrc(elem, options) {
const item = options.items[0];
this.currentItem = item;
this.item = item;
this.streamInfo = {
started: true,
ended: false,
item: this.item,
mediaSource: {
Id: item.Id
}
};
loading.show();
@ -134,6 +181,10 @@ export class ComicsPlayer {
return this.archiveSource.load().then(() => {
loading.hide();
this.pageCount = this.archiveSource.urls.length;
this.currentPage = options.startPositionTicks / 10000 || 0;
this.swiperInstance = new Swiper(elem.querySelector('.slideshowSwiperContainer'), {
direction: 'horizontal',
// loop is disabled due to the lack of Swiper support in virtual slides
@ -150,7 +201,7 @@ export class ComicsPlayer {
preloadImages: true,
slidesPerView: 1,
slidesPerColumn: 1,
initialSlide: 0,
initialSlide: this.currentPage,
// reduces memory consumption for large libraries while allowing preloading of images
virtual: {
slides: this.archiveSource.urls,
@ -160,6 +211,12 @@ export class ComicsPlayer {
addSlidesAfter: 1
}
});
// save current page ( a page is an image file inside the archive )
this.swiperInstance.on('slideChange', () => {
this.currentPage = this.swiperInstance.activeIndex;
Events.trigger(this, 'pause');
});
});
}