External Subtitles don't get displayed
See original GitHub issueHave you read the FAQ and checked for duplicate open issues?:
Yes
What version of Shaka Player are you using?:
2.4.4, 2.5.0-beta
Can you reproduce the issue with our latest release version?:
Yes
Can you reproduce the issue with the latest code from master?:
Have not tried
Are you using the demo app or your own custom app?:
Custom
If custom app, can you reproduce the issue using our demo app?:
Unsure how
What browser and OS are you using?:
Chrome 69.0.3497.100
Windows 10
What are the manifest and license server URIs?:
Any
What did you do?
Added subtitle track via addTextTrack, but is not shown or selectable via the UI
player.load(manifestUri).then(function() {
player.addTextTrack('/darkroom_timer.vtt', 'eng', 'subtitle', 'text/vtt', '', 'English')
}).catch(onError);
What did you expect to happen?
When hitting the CC button, to have the option of a ‘English’ subtitle. This works if adding it in the <track> section of the HTML manually.
What actually happened?
Hitting CC only showed the usual ‘Shaka Player TextTrack’ and selecting it did nothing.

** Additional **
I am very new to using this, so it is probably user error, but have tried for a few days to no avail. Any help would be appreciated!
WebVTT file
WEBVTT
00:01.000 --> 00:03.000
This is a custom darkroom timer
00:04.000 --> 00:07.000
Created with a raspberry pi
HTML File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/2.5.0-beta/shaka-player.compiled.debug.js" type="application/javascript"></script>
</head>
<body>
<video id="video"
width="640"
controls autoplay>
<!--<track label="English" kind="subtitles" srclang="eng" src="/darkroom_timer.vtt" type="text/vtt" >-->
</video>
<script>
var manifestUri = '/output/stream.mpd';
function initApp() {
shaka.polyfill.installAll();
if (shaka.Player.isBrowserSupported()) {
initPlayer();
} else {
console.error('Browser not supported!');
}
}
function initPlayer() {
var video = document.getElementById('video');
var player = new shaka.Player(video);
player.configure({
drm: {
clearKeys: {
'11111111111111111111111111111111': '11111111111111111111111111111111',
}
},
preferredTextLanguage: 'eng',
preferredAudioLanguage: 'eng',
streaming: {
bufferingGoal: 120
}
}
);
window.player = player;
player.addEventListener('error', onErrorEvent);
player.load(manifestUri).then(function() {
player.addTextTrack('/darkroom_timer.vtt', 'eng', 'subtitle', 'text/vtt', '', 'English')
console.log('The video has now been loaded!');
}).catch(onError);
}
function onErrorEvent(event) {
onError(event.detail);
}
function onError(error) {
console.error('Error code', error.code, 'object', error);
}
document.addEventListener('DOMContentLoaded', initApp);
</script>
</body>
</html>
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (6 by maintainers)

Top Related StackOverflow Question
FYI, we are currently working on a UI layer for the player, that will allow for text track selection from the UI, listing all the text tracks available.
The one native track represents what is currently streaming from Shaka Player. You can change what we stream using
player.selectTextLanguageorplayer.selectTextTrack; you can query languages and tracks withplayer.getTextLanguagesandplayer.getTextTracksrespectively. By default we play the latest added, but you can change this later.Also note that if you are using native controls, you may need to set the
streaming.alwaysStreamTextconfiguration to ensure we play it. We have no way of detecting when the text track is showing. By default we only download text streams when they are visible. So if you change the native track’s visibility without using the player (player.setTextTrackVisbility), then we won’t stream it. You can set to always stream text withplayer.configure('streaming.alwaysStreamText', true).As for why we only have one native track, it is because we want to stream only what is being displayed. If we had multiple native tracks for different languages, we would have to download all of them since it would be hard (or impossible) to determine which is currently displayed and get events when it changes. So we reuse the same native track and handle buffering and changing languages internally.