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

Make book player display an error on non-epub books

This commit is contained in:
Daniyar Itegulov 2020-05-28 18:39:49 +10:00
parent 2201d693e2
commit c7a89ae74b
No known key found for this signature in database
GPG key ID: 4DB862B7839037FD
2 changed files with 25 additions and 2 deletions

View file

@ -170,13 +170,32 @@ export class BookPlayer {
} }
setCurrentSrc(elem, options) { setCurrentSrc(elem, options) {
let serverId = options.items[0].ServerId; let item = options.items[0];
if (!item.Path.endsWith('.epub')) {
return new Promise((resolve, reject) => {
let errorDialog = dialogHelper.createDialog({
size: 'small',
autoFocus: false,
removeOnClose: true
});
errorDialog.innerHTML = '<h1 class="bookplayerErrorMsg">This book type is not supported yet</h1>';
this.stop();
dialogHelper.open(errorDialog);
loading.hide();
return resolve();
});
}
let serverId = item.ServerId;
let apiClient = connectionManager.getApiClient(serverId); let apiClient = connectionManager.getApiClient(serverId);
const self = this; const self = this;
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
require(['epubjs'], function (epubjs) { require(['epubjs'], function (epubjs) {
let downloadHref = apiClient.getItemDownloadUrl(options.items[0].Id); let downloadHref = apiClient.getItemDownloadUrl(item.Id);
let book = epubjs.default(downloadHref, {openAs: 'epub'}); let book = epubjs.default(downloadHref, {openAs: 'epub'});
let rendition = book.renderTo(elem, {width: '100%', height: '97%'}); let rendition = book.renderTo(elem, {width: '100%', height: '97%'});

View file

@ -33,3 +33,7 @@
.toc li { .toc li {
margin-bottom: 5px; margin-bottom: 5px;
} }
.bookplayerErrorMsg {
text-align: center;
}