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
|
||||
*/
|
||||
renderSsaAss(videoElement, track, item) {
|
||||
const supportedFonts = ['application/vnd.ms-opentype', 'application/x-truetype-font', 'font/otf', 'font/ttf', 'font/woff', 'font/woff2'];
|
||||
const availableFonts = [];
|
||||
const supportedFontMimeTypes = ['application/vnd.ms-opentype', 'application/x-truetype-font', 'font/otf', 'font/ttf', 'font/woff', 'font/woff2'];
|
||||
const fontsToPreload = [];
|
||||
const attachments = this._currentPlayOptions.mediaSource.MediaAttachments || [];
|
||||
const apiClient = ServerConnections.getApiClient(item);
|
||||
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
|
||||
if (supportedFonts.includes(i.MimeType)) {
|
||||
if (supportedFontMimeTypes.includes(i.MimeType)) {
|
||||
// embedded font url
|
||||
availableFonts.push(apiClient.getUrl(i.DeliveryUrl));
|
||||
fontsToPreload.push(apiClient.getUrl(i.DeliveryUrl));
|
||||
}
|
||||
});
|
||||
const fallbackFontList = apiClient.getUrl('/FallbackFont/Fonts', {
|
||||
|
@ -1286,7 +1286,7 @@ export class HtmlVideoPlayer {
|
|||
const options = {
|
||||
video: videoElement,
|
||||
subUrl: getTextTrackUrl(track, item),
|
||||
fonts: availableFonts,
|
||||
fonts: fontsToPreload,
|
||||
workerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker.js`,
|
||||
legacyWorkerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker-legacy.js`,
|
||||
onError() {
|
||||
|
@ -1324,12 +1324,19 @@ export class HtmlVideoPlayer {
|
|||
|
||||
if (config.EnableFallbackFont) {
|
||||
apiClient.getJSON(fallbackFontList).then((fontFiles = []) => {
|
||||
const availableFonts = {};
|
||||
fontFiles.forEach(font => {
|
||||
const fontUrl = apiClient.getUrl(`/FallbackFont/Fonts/${encodeURIComponent(font.Name)}`, {
|
||||
api_key: apiClient.accessToken()
|
||||
});
|
||||
availableFonts.push(fontUrl);
|
||||
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)}`, {
|
||||
api_key: apiClient.accessToken()
|
||||
});
|
||||
availableFonts[familyNameLower] = fontUrl;
|
||||
}
|
||||
});
|
||||
options.availableFonts = availableFonts;
|
||||
this.#currentAssRenderer = new SubtitlesOctopus(options);
|
||||
});
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue