mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge d821ad3562
into 7d84185d0e
This commit is contained in:
commit
5eed1c3c72
1 changed files with 16 additions and 9 deletions
|
@ -1264,15 +1264,15 @@ export class HtmlVideoPlayer {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
renderSsaAss(videoElement, track, item) {
|
renderSsaAss(videoElement, track, item) {
|
||||||
const supportedFonts = ['application/vnd.ms-opentype', 'application/x-truetype-font', 'font/otf', 'font/ttf', 'font/woff', 'font/woff2'];
|
const supportedFontMimeTypes = ['application/vnd.ms-opentype', 'application/x-truetype-font', 'font/otf', 'font/ttf', 'font/woff', 'font/woff2'];
|
||||||
const availableFonts = [];
|
const fontsToPreload = [];
|
||||||
const attachments = this._currentPlayOptions.mediaSource.MediaAttachments || [];
|
const attachments = this._currentPlayOptions.mediaSource.MediaAttachments || [];
|
||||||
const apiClient = ServerConnections.getApiClient(item);
|
const apiClient = ServerConnections.getApiClient(item);
|
||||||
attachments.forEach(i => {
|
attachments.forEach(i => {
|
||||||
// we only require font files and ignore embedded media attachments like covers as there are cases where ffmpeg fails to extract those
|
// we only require font files and ignore embedded media attachments like covers as there are cases where ffmpeg fails to extract those
|
||||||
if (supportedFonts.includes(i.MimeType)) {
|
if (supportedFontMimeTypes.includes(i.MimeType)) {
|
||||||
// embedded font url
|
// embedded font url
|
||||||
availableFonts.push(apiClient.getUrl(i.DeliveryUrl));
|
fontsToPreload.push(apiClient.getUrl(i.DeliveryUrl));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const fallbackFontList = apiClient.getUrl('/FallbackFont/Fonts', {
|
const fallbackFontList = apiClient.getUrl('/FallbackFont/Fonts', {
|
||||||
|
@ -1286,7 +1286,7 @@ export class HtmlVideoPlayer {
|
||||||
const options = {
|
const options = {
|
||||||
video: videoElement,
|
video: videoElement,
|
||||||
subUrl: getTextTrackUrl(track, item),
|
subUrl: getTextTrackUrl(track, item),
|
||||||
fonts: availableFonts,
|
fonts: fontsToPreload,
|
||||||
workerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker.js`,
|
workerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker.js`,
|
||||||
legacyWorkerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker-legacy.js`,
|
legacyWorkerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker-legacy.js`,
|
||||||
onError() {
|
onError() {
|
||||||
|
@ -1324,12 +1324,19 @@ export class HtmlVideoPlayer {
|
||||||
|
|
||||||
if (config.EnableFallbackFont) {
|
if (config.EnableFallbackFont) {
|
||||||
apiClient.getJSON(fallbackFontList).then((fontFiles = []) => {
|
apiClient.getJSON(fallbackFontList).then((fontFiles = []) => {
|
||||||
|
const availableFonts = {};
|
||||||
fontFiles.forEach(font => {
|
fontFiles.forEach(font => {
|
||||||
|
if (!font.FamilyName) return;
|
||||||
|
if (font.Size > 20 * 1024 * 1024) return; // max 20 MB for any single font file
|
||||||
|
const familyNameLower = font.FamilyName.trim().toLowerCase();
|
||||||
|
if (!(familyNameLower in availableFonts)) {
|
||||||
const fontUrl = apiClient.getUrl(`/FallbackFont/Fonts/${encodeURIComponent(font.Name)}`, {
|
const fontUrl = apiClient.getUrl(`/FallbackFont/Fonts/${encodeURIComponent(font.Name)}`, {
|
||||||
api_key: apiClient.accessToken()
|
api_key: apiClient.accessToken()
|
||||||
});
|
});
|
||||||
availableFonts.push(fontUrl);
|
availableFonts[familyNameLower] = fontUrl;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
options.availableFonts = availableFonts;
|
||||||
this.#currentAssRenderer = new SubtitlesOctopus(options);
|
this.#currentAssRenderer = new SubtitlesOctopus(options);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue