Does Chromecast support TTML?

烈酒焚心 提交于 2019-12-14 03:19:54

问题


The Chromecast developer docs say both WebVTT and TTML are Supported Media Types: https://developers.google.com/cast/supported_media_types


I see captions when using a WebVTT file in a "track" tag within a video element:

<video id="vid" src="http://myurl">
    <track kind="captions" src="http://10.16.236.23/test.vtt" srclang="en" label="English" default>
</video>

But when I try to do the same using a valid TTML file, I don't see captions:

<video id="vid" src="http://myurl">
    <track kind="captions" src="test.ttml" srclang="en" label="English" default>
</video>


When I inspect the video element in the debugger console, for the WebVTT example I can see

document.getElementById('vid').textTracks[0].cues.length;

16

but for TTML:

document.getElementById('vid').textTracks[0].cues.length;

0


I am on the right track with this or is TTML supported in a different way? Maybe my TTML syntax is not supported by Chromecast?


回答1:


Unlike webVTT, TTML is not natively supported. If you need to support that in your app, you can simply write a Javascript parser to parse the file and add the cues to your video element in javascript using methods such as addTextTrack(), etc.




回答2:


According to the Cast Player API, Chromecast now supports WebVTT, TTML1, and CEA-608 (Line 21 Captions) caption formats. Just pass in the CaptionsType enum for your caption format into the player's enableCaptions() method.



来源:https://stackoverflow.com/questions/19572313/does-chromecast-support-ttml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!