Description
As I understand it there is some work planned to look at subtitles, TTML and subtitle playlists. Dash itself has the concept of an adaption set for subtitles.
I was looking to add subtitles and potentially captions as well. While the implementation for each is essentially the same there is a semantic difference that I would like to capture.
I currently pass something like html5 tracks structure to our player and then inturn pass that to the shakaplayer.
tracks: [
{
kind: 'subtitles',
src: '/subtitles-en.vtt',
srclang: 'en'
},
{
kind: 'captions',
src: '/captions-en.vtt',
srclang: 'en'
}
]
The shakaplayer accepts a call like this
addExternalCaptions('/subtitles-en.vtt', 'en', 'text/vtt');
addExternalCaptions('/captions-en.vtt', 'en', 'text/vtt');
But once these are added there is no easy way to distinguish between them. As calling getTextTracks()
will return
0: {
active: true,
enabled: false,
id: 2,
lang: "en"
},
1: {
active: false,
enabled: false,
id: 3,
lang: "en"
}
There is no information that indicates that one is a subtitle and the other is a caption. Even if I call addExternalCaptions with a mime type extension like 'text/vtt+caption' that information is not available.
Ultimately I would like to create a UI to allow the user to select a subtitle or a caption in their language.
I could manage the association between my tracks structure and the getTextTracks but there a couple of assumptions I need to make. Either I assume that the call to getTextTracks will return the results in the same order that I called addExternalCaptions which is probably a safe thing to do, or I take the index of my tracks list and add +2 before calling selectTextTrack(index + 2);
which seems a little mysterious (I'm experienced in off by one errors but off by two are less common:)).
Perhaps the cleanest way would be to return the TextTrack object from the call to addExternalCaptions so I know which text track this refers to. Currently addExternalCaptions returns undefined.
An alternative would be to enrich the current text track model with a friendly name and perhaps even the kind into the call addExternalCaptions('/subtitles-en.vtt', 'en', 'text/vtt', 'English');
which can be queried via getTextTracks()
. This better aligns with the HTML5 specification.
I hope that made sense