зеркало из https://github.com/GoogleChrome/kino.git
Add a default subtitles track in Google Cast.
This commit is contained in:
Родитель
949d957aed
Коммит
fc208799eb
|
@ -23,7 +23,7 @@ video-subtitles:
|
|||
kind: captions
|
||||
label: Česky
|
||||
src: https://storage.googleapis.com/kino-assets/using-webvtt/cap-cz.vtt
|
||||
srclang: cz
|
||||
srclang: cs
|
||||
thumbnail: https://storage.googleapis.com/kino-assets/using-webvtt/thumbnail.png
|
||||
media-session-artwork:
|
||||
- sizes: 96x96
|
||||
|
|
|
@ -21,7 +21,7 @@ video-subtitles:
|
|||
kind: captions
|
||||
label: Česky
|
||||
src: https://storage.googleapis.com/kino-assets/streaming-basics/cap-cz.vtt
|
||||
srclang: cz
|
||||
srclang: cs
|
||||
thumbnail: https://storage.googleapis.com/kino-assets/streaming-basics/thumbnail.png
|
||||
media-session-artwork:
|
||||
- sizes: 96x96
|
||||
|
|
|
@ -21,7 +21,7 @@ video-subtitles:
|
|||
kind: captions
|
||||
label: Česky
|
||||
src: https://storage.googleapis.com/kino-assets/efficient-formats/cap-cz.vtt
|
||||
srclang: cz
|
||||
srclang: cs
|
||||
thumbnail: https://storage.googleapis.com/kino-assets/efficient-formats/thumbnail.png
|
||||
media-session-artwork:
|
||||
- sizes: 96x96
|
||||
|
|
|
@ -21,7 +21,7 @@ video-subtitles:
|
|||
kind: captions
|
||||
label: Česky
|
||||
src: https://storage.googleapis.com/kino-assets/adaptive-streaming/cap-cz.vtt
|
||||
srclang: cz
|
||||
srclang: cs
|
||||
thumbnail: https://storage.googleapis.com/kino-assets/adaptive-streaming/thumbnail.png
|
||||
media-session-artwork:
|
||||
- sizes: 96x96
|
||||
|
|
|
@ -145,6 +145,30 @@ export default class extends HTMLElement {
|
|||
metadata.images = [videoThumbnail];
|
||||
mediaInfo.metadata = metadata;
|
||||
|
||||
const subtitles = this.internal.videoData['video-subtitles'] || [];
|
||||
const defaultSubtitles = subtitles.find((subtitle) => subtitle.default);
|
||||
|
||||
/**
|
||||
* AFAICT the Default Media Receiver doesn't implement any UI to
|
||||
* select the subtitle track.
|
||||
*
|
||||
* We only add the subtitle track if there is a default one.
|
||||
*/
|
||||
if (defaultSubtitles) {
|
||||
const defaultSubtitlesTrack = new window.chrome.cast.media.Track(
|
||||
1,
|
||||
window.chrome.cast.media.TrackType.TEXT,
|
||||
);
|
||||
|
||||
defaultSubtitlesTrack.trackContentId = defaultSubtitles.src;
|
||||
defaultSubtitlesTrack.subtype = window.chrome.cast.media.TextTrackType.SUBTITLES;
|
||||
defaultSubtitlesTrack.name = defaultSubtitles.label;
|
||||
defaultSubtitlesTrack.language = defaultSubtitles.srclang;
|
||||
defaultSubtitlesTrack.trackContentType = 'text/vtt';
|
||||
|
||||
mediaInfo.tracks = [defaultSubtitlesTrack];
|
||||
}
|
||||
|
||||
const request = new window.chrome.cast.media.LoadRequest(mediaInfo);
|
||||
|
||||
try {
|
||||
|
|
Загрузка…
Ссылка в новой задаче