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

Merge pull request #2093 from thornbill/fix-pdfjs

Fix pdfjs import
This commit is contained in:
dkanada 2020-11-21 19:38:26 +09:00 committed by GitHub
commit 1f16adbe1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ import { appRouter } from '../../components/appRouter';
import './style.css'; import './style.css';
import '../../elements/emby-button/paper-icon-button-light'; import '../../elements/emby-button/paper-icon-button-light';
import { Events } from 'jellyfin-apiclient'; import { Events } from 'jellyfin-apiclient';
import { GlobalWorkerOptions, getDocument } from 'pdfjs-dist';
export class PdfPlayer { export class PdfPlayer {
constructor() { constructor() {
@ -189,13 +190,12 @@ export class PdfPlayer {
const apiClient = ServerConnections.getApiClient(serverId); const apiClient = ServerConnections.getApiClient(serverId);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
import('pdfjs-dist').then(({default: pdfjs}) => {
const downloadHref = apiClient.getItemDownloadUrl(item.Id); const downloadHref = apiClient.getItemDownloadUrl(item.Id);
this.bindEvents(); this.bindEvents();
pdfjs.GlobalWorkerOptions.workerSrc = appRouter.baseUrl() + '/libraries/pdf.worker.js'; GlobalWorkerOptions.workerSrc = appRouter.baseUrl() + '/libraries/pdf.worker.js';
const downloadTask = pdfjs.getDocument(downloadHref); const downloadTask = getDocument(downloadHref);
downloadTask.promise.then(book => { downloadTask.promise.then(book => {
if (this.cancellationToken) return; if (this.cancellationToken) return;
this.book = book; this.book = book;
@ -212,7 +212,6 @@ export class PdfPlayer {
return resolve(); return resolve();
}); });
}); });
});
} }
next() { next() {