mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Save progress when reading a comic book archive
This commit is contained in:
parent
e1c5f809c8
commit
5115500443
2 changed files with 59 additions and 4 deletions
|
@ -49,6 +49,7 @@
|
||||||
- [Ömer Erdinç Yağmurlu](https://github.com/omeryagmurlu)
|
- [Ömer Erdinç Yağmurlu](https://github.com/omeryagmurlu)
|
||||||
- [Keegan Dahm](https://github.com/keegandahm)
|
- [Keegan Dahm](https://github.com/keegandahm)
|
||||||
- [GodTamIt](https://github.com/GodTamIt)
|
- [GodTamIt](https://github.com/GodTamIt)
|
||||||
|
- [MinecraftPlaye](https://github.com/MinecraftPlaye)
|
||||||
|
|
||||||
# Emby Contributors
|
# Emby Contributors
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,17 @@ export class ComicsPlayer {
|
||||||
return this.setCurrentSrc(elem, options);
|
return this.setCurrentSrc(elem, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destroy() {
|
||||||
|
// Nothing to do here
|
||||||
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
this.unbindEvents();
|
this.unbindEvents();
|
||||||
|
const stopInfo = {
|
||||||
|
src: this.item
|
||||||
|
};
|
||||||
|
|
||||||
|
Events.trigger(this, 'stopped', [stopInfo]);
|
||||||
this.archiveSource?.release();
|
this.archiveSource?.release();
|
||||||
|
|
||||||
const elem = this.mediaElement;
|
const elem = this.mediaElement;
|
||||||
|
@ -44,6 +52,36 @@ export class ComicsPlayer {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentTime() {
|
||||||
|
// * 1000 is an arbitrary value copied over from the bookPlayer
|
||||||
|
return this.progress * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
duration() {
|
||||||
|
// 1000 is an arbitrary value copied over from the bookPlayer
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentItem() {
|
||||||
|
return this.item;
|
||||||
|
}
|
||||||
|
|
||||||
|
volume() {
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
isMuted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
paused() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
seekable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
onDialogClosed() {
|
onDialogClosed() {
|
||||||
this.stop();
|
this.stop();
|
||||||
}
|
}
|
||||||
|
@ -60,8 +98,8 @@ export class ComicsPlayer {
|
||||||
bindMediaElementEvents() {
|
bindMediaElementEvents() {
|
||||||
const elem = this.mediaElement;
|
const elem = this.mediaElement;
|
||||||
|
|
||||||
elem?.addEventListener('close', this.onDialogClosed, {once: true});
|
elem?.addEventListener('close', this.onDialogClosed, { once: true });
|
||||||
elem?.querySelector('.btnExit').addEventListener('click', this.onDialogClosed, {once: true});
|
elem?.querySelector('.btnExit').addEventListener('click', this.onDialogClosed, { once: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
bindEvents() {
|
bindEvents() {
|
||||||
|
@ -118,7 +156,15 @@ export class ComicsPlayer {
|
||||||
|
|
||||||
setCurrentSrc(elem, options) {
|
setCurrentSrc(elem, options) {
|
||||||
const item = options.items[0];
|
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();
|
loading.show();
|
||||||
|
|
||||||
|
@ -134,6 +180,8 @@ export class ComicsPlayer {
|
||||||
|
|
||||||
return this.archiveSource.load().then(() => {
|
return this.archiveSource.load().then(() => {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
|
||||||
|
this.progress = options.startPositionTicks / 10000000 || 0;
|
||||||
this.swiperInstance = new Swiper(elem.querySelector('.slideshowSwiperContainer'), {
|
this.swiperInstance = new Swiper(elem.querySelector('.slideshowSwiperContainer'), {
|
||||||
direction: 'horizontal',
|
direction: 'horizontal',
|
||||||
// loop is disabled due to the lack of Swiper support in virtual slides
|
// loop is disabled due to the lack of Swiper support in virtual slides
|
||||||
|
@ -150,7 +198,7 @@ export class ComicsPlayer {
|
||||||
preloadImages: true,
|
preloadImages: true,
|
||||||
slidesPerView: 1,
|
slidesPerView: 1,
|
||||||
slidesPerColumn: 1,
|
slidesPerColumn: 1,
|
||||||
initialSlide: 0,
|
initialSlide: this.progress * this.archiveSource.urls.length,
|
||||||
// reduces memory consumption for large libraries while allowing preloading of images
|
// reduces memory consumption for large libraries while allowing preloading of images
|
||||||
virtual: {
|
virtual: {
|
||||||
slides: this.archiveSource.urls,
|
slides: this.archiveSource.urls,
|
||||||
|
@ -160,6 +208,12 @@ export class ComicsPlayer {
|
||||||
addSlidesAfter: 1
|
addSlidesAfter: 1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// save current page ( a page is an image file inside the archive )
|
||||||
|
this.swiperInstance.on('slideChange', () => {
|
||||||
|
this.progress = this.swiperInstance.activeIndex / this.archiveSource.urls.length;
|
||||||
|
Events.trigger(this, 'pause');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue