Fix CORS header on local subtitles

This commit is contained in:
hensm
2020-01-19 22:08:14 +00:00
parent d90bb008fb
commit bbfc380f4a
2 changed files with 3 additions and 1 deletions

View File

@@ -441,6 +441,8 @@ async function handleMediaServerMessage (message: Message) {
const vttSource = subtitles.get(req.url)!;
const vttStream = stream.Readable.from(vttSource);
res.setHeader("Access-Control-Allow-Origin", "*");
vttStream.pipe(res);
}

View File

@@ -188,7 +188,7 @@ function getMedia (opts: InitOptions): Promise<cast.media.Media> {
trackIndex, cast.media.TrackType.TEXT);
// Copy TextTrack properties
castTrack.name = track.label;
castTrack.name = track.label || `track-${trackIndex}`;
castTrack.language = track.language;
castTrack.trackContentId = trackElement.src;
castTrack.trackContentType = "text/vtt";