1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Store each page as a tick

This commit is contained in:
Patrick Farwick 2021-10-05 20:20:33 +00:00
parent 22b1063629
commit b3056ee321

View file

@ -24,7 +24,8 @@ export class ComicsPlayer {
} }
play(options) { play(options) {
this.progress = 0; this.currentPage = 0;
this.pageCount = 0;
const elem = this.createMediaElement(); const elem = this.createMediaElement();
return this.setCurrentSrc(elem, options); return this.setCurrentSrc(elem, options);
@ -55,13 +56,12 @@ export class ComicsPlayer {
} }
currentTime() { currentTime() {
// * 1000 is an arbitrary value copied over from the bookPlayer return this.currentPage;
return this.progress * 1000;
} }
duration() { duration() {
// 1000 is an arbitrary value copied over from the bookPlayer // 1000 is an arbitrary value copied over from the bookPlayer
return 1000; return this.pageCount;
} }
currentItem() { currentItem() {
@ -183,7 +183,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.pageCount = this.archiveSource.urls.length;
this.currentPage = options.startPositionTicks / 10000 || 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
@ -200,7 +201,7 @@ export class ComicsPlayer {
preloadImages: true, preloadImages: true,
slidesPerView: 1, slidesPerView: 1,
slidesPerColumn: 1, slidesPerColumn: 1,
initialSlide: this.progress * this.archiveSource.urls.length, initialSlide: this.currentPage,
// 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,
@ -213,7 +214,7 @@ export class ComicsPlayer {
// save current page ( a page is an image file inside the archive ) // save current page ( a page is an image file inside the archive )
this.swiperInstance.on('slideChange', () => { this.swiperInstance.on('slideChange', () => {
this.progress = this.swiperInstance.activeIndex / this.archiveSource.urls.length; this.currentPage = this.swiperInstance.activeIndex;
Events.trigger(this, 'pause'); Events.trigger(this, 'pause');
}); });
}); });