Supporting custom fonts

This commit is contained in:
Zoe Roux 2020-10-31 03:38:28 +01:00
parent a006cc3f9f
commit 0ed1b8afc0
2 changed files with 12 additions and 3 deletions

View File

@ -15,6 +15,7 @@ import { DomSanitizer, Title } from "@angular/platform-browser";
import { ActivatedRoute, Event, NavigationCancel, NavigationEnd, NavigationStart, Router } from "@angular/router"; import { ActivatedRoute, Event, NavigationCancel, NavigationEnd, NavigationStart, Router } from "@angular/router";
import { OidcSecurityService } from "angular-auth-oidc-client"; import { OidcSecurityService } from "angular-auth-oidc-client";
import * as Hls from "hls.js"; import * as Hls from "hls.js";
import { ShowService } from "../../services/api.service";
import { import {
getWhatIsSupported, getWhatIsSupported,
method, method,
@ -160,7 +161,8 @@ export class PlayerComponent implements OnInit, OnDestroy, AfterViewInit
private title: Title, private title: Title,
private router: Router, private router: Router,
private location: Location, private location: Location,
private injector: Injector) private injector: Injector,
private shows: ShowService)
{ } { }
ngOnInit() ngOnInit()
@ -405,7 +407,7 @@ export class PlayerComponent implements OnInit, OnDestroy, AfterViewInit
document.body.requestFullscreen(); document.body.requestFullscreen();
} }
selectSubtitle(subtitle: Track | number, changeUrl: boolean = true) async selectSubtitle(subtitle: Track | number, changeUrl: boolean = true)
{ {
if (typeof(subtitle) === "number") if (typeof(subtitle) === "number")
{ {
@ -460,9 +462,11 @@ export class PlayerComponent implements OnInit, OnDestroy, AfterViewInit
{ {
if (!this.subtitlesManager) if (!this.subtitlesManager)
{ {
let fonts: {[key: string]: string} = await this.shows.getFonts(this.item.showSlug).toPromise();
this.subtitlesManager = new SubtitlesOctopus({ this.subtitlesManager = new SubtitlesOctopus({
video: this.player, video: this.player,
subUrl: `subtitle/${subtitle.slug}` subUrl: `subtitle/${subtitle.slug}`,
fonts: Object.values(fonts)
}); });
} }
else else

View File

@ -159,6 +159,11 @@ export class ShowService extends CrudApi<Show>
return this.client.get<Page<Show>>(`/api/collections/${collection}/shows${this.ArgsAsQuery(args)}`) return this.client.get<Page<Show>>(`/api/collections/${collection}/shows${this.ArgsAsQuery(args)}`)
.pipe(map(x => Object.assign(new Page<Show>(), x))); .pipe(map(x => Object.assign(new Page<Show>(), x)));
} }
getFonts(id: string | number): Observable<{[font: string]: string}>
{
return this.client.get<any>(`/api/shows/${id}/fonts`);
}
} }
@Injectable({ @Injectable({