mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
basic skeleton for epub reader
This commit is contained in:
parent
1e269f2b27
commit
8478b0ed56
6 changed files with 54 additions and 3 deletions
|
@ -59,6 +59,7 @@
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"date-fns": "^2.13.0",
|
"date-fns": "^2.13.0",
|
||||||
"document-register-element": "^1.14.3",
|
"document-register-element": "^1.14.3",
|
||||||
|
"epubjs": "^0.3.85",
|
||||||
"fast-text-encoding": "^1.0.1",
|
"fast-text-encoding": "^1.0.1",
|
||||||
"flv.js": "^1.5.0",
|
"flv.js": "^1.5.0",
|
||||||
"headroom.js": "^0.11.0",
|
"headroom.js": "^0.11.0",
|
||||||
|
|
|
@ -96,6 +96,14 @@ div[data-role=page] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#bookPlayer {
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
z-index: 100;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
.headerHelpButton {
|
.headerHelpButton {
|
||||||
margin-left: 1.25em !important;
|
margin-left: 1.25em !important;
|
||||||
padding-bottom: 0.4em !important;
|
padding-bottom: 0.4em !important;
|
||||||
|
|
|
@ -102,6 +102,11 @@ _define('jellyfin-noto', function () {
|
||||||
return noto;
|
return noto;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var epubjs = require('epubjs');
|
||||||
|
_define('epubjs', function () {
|
||||||
|
return epubjs;
|
||||||
|
});
|
||||||
|
|
||||||
// page.js
|
// page.js
|
||||||
var page = require('page');
|
var page = require('page');
|
||||||
_define('page', function() {
|
_define('page', function() {
|
||||||
|
|
35
src/components/bookplayer/plugin.js
Normal file
35
src/components/bookplayer/plugin.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
define(['connectionManager', 'dom'], function (connectionManager, dom) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function BookPlayer() {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
self.name = 'Book Player';
|
||||||
|
self.type = 'mediaplayer';
|
||||||
|
self.id = 'bookplayer';
|
||||||
|
self.priority = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BookPlayer.prototype.play = function (values) {
|
||||||
|
var serverId = values.items[0].ServerId
|
||||||
|
var apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
var options = values;
|
||||||
|
|
||||||
|
require(['epubjs', 'appFooter-shared'], function (epubjs, appFooter) {
|
||||||
|
appFooter.element.insertAdjacentHTML('beforebegin', '<div id="bookPlayer"></div>');
|
||||||
|
var element = document.getElementById('bookPlayer');
|
||||||
|
|
||||||
|
var downloadHref = apiClient.getItemDownloadUrl(options.items[0].Id);
|
||||||
|
|
||||||
|
var book = epubjs.default(downloadHref, { openAs: 'epub' });
|
||||||
|
var rendition = book.renderTo(element, { method: "continuous", width: "100%", height: "100%" });
|
||||||
|
var displayed = rendition.display();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BookPlayer.prototype.canPlayMediaType = function (mediaType) {
|
||||||
|
return (mediaType || '').toLowerCase() === 'book';
|
||||||
|
};
|
||||||
|
|
||||||
|
return BookPlayer;
|
||||||
|
});
|
|
@ -2182,7 +2182,7 @@ define(['events', 'datetime', 'appSettings', 'itemHelper', 'pluginManager', 'pla
|
||||||
// Only used internally
|
// Only used internally
|
||||||
self.getCurrentTicks = getCurrentTicks;
|
self.getCurrentTicks = getCurrentTicks;
|
||||||
|
|
||||||
function playPhotos(items, options, user) {
|
function playOther(items, options, user) {
|
||||||
|
|
||||||
var playStartIndex = options.startIndex || 0;
|
var playStartIndex = options.startIndex || 0;
|
||||||
var player = getPlayer(items[playStartIndex], options);
|
var player = getPlayer(items[playStartIndex], options);
|
||||||
|
@ -2211,9 +2211,9 @@ define(['events', 'datetime', 'appSettings', 'itemHelper', 'pluginManager', 'pla
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstItem.MediaType === 'Photo') {
|
if (firstItem.MediaType === 'Photo' || firstItem.MediaType === 'Book') {
|
||||||
|
|
||||||
return playPhotos(items, options, user);
|
return playOther(items, options, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
var apiClient = connectionManager.getApiClient(firstItem.ServerId);
|
var apiClient = connectionManager.getApiClient(firstItem.ServerId);
|
||||||
|
|
|
@ -484,6 +484,7 @@ var AppInfo = {};
|
||||||
'components/htmlAudioPlayer/plugin',
|
'components/htmlAudioPlayer/plugin',
|
||||||
'components/htmlVideoPlayer/plugin',
|
'components/htmlVideoPlayer/plugin',
|
||||||
'components/photoPlayer/plugin',
|
'components/photoPlayer/plugin',
|
||||||
|
'components/bookplayer/plugin',
|
||||||
'components/youtubeplayer/plugin',
|
'components/youtubeplayer/plugin',
|
||||||
'components/backdropScreensaver/plugin',
|
'components/backdropScreensaver/plugin',
|
||||||
'components/logoScreensaver/plugin'
|
'components/logoScreensaver/plugin'
|
||||||
|
@ -670,6 +671,7 @@ var AppInfo = {};
|
||||||
'fetch',
|
'fetch',
|
||||||
'flvjs',
|
'flvjs',
|
||||||
'jstree',
|
'jstree',
|
||||||
|
'epubjs',
|
||||||
'jQuery',
|
'jQuery',
|
||||||
'hlsjs',
|
'hlsjs',
|
||||||
'howler',
|
'howler',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue