我正在尝试在Chromecast自定义接收器应用程序上播放带有多个插播字幕的视频,但它无法正常工作。这是我用于启用字幕流的代码:
mediaElement.addEventListener('playing', function(e) {
setStreamLanguage('text', 'fin');
player.enableCaptions(true);
});
function setStreamLanguage(streamType, languageCode){
var streamInfo;
var streamToEnable = -1;
for(var i = 0; i < protocol.getStreamCount(); ++i) {
streamInfo = protocol.getStreamInfo(i);
if (streamInfo.mimeType.indexOf(streamType) == 0) {
// select first stream by default in case there are no passed stream
if (streamToEnable < 0)
streamToEnable = i;
// disable all stream
protocol.enableStream(i, false);
// find a stream to enable
if (streamInfo.language == languageCode)
streamToEnable = i;
console.log('cycling throught: ' + streamInfo.mimeType + " " + streamInfo.language + " " +
"is selected: " + protocol.isStreamEnabled(i));
}
}
if (streamToEnable >= 0)
{
protocol.enableStream(streamToEnable, true);
console.log("stream " + streamToEnable + " is enabled now");
}
}
因此正在播放视频,但不显示字幕。控制台中也有错误:“未捕获URIError:URI格式错误”。
以下是用于测试的清单:http://usp.neonstingray.com/video/13440/13440.ism/Manifest。
以下是chromecast接收器日志:https://gist.github.com/anonymous/e992c306602fb3cb5b8a