【发布时间】:2017-08-27 06:32:56
【问题描述】:
我的需要
html5 视频元素加载保存在不同域中的视频和 vtt 文件。
问题
vtt 未加载,错误Text track from origin has been blocked from loading: Not at same origin as the document, and parent of track element does not have a 'crossorigin' attribute.
我的调查
我知道需要使用 CORS 才能在 html5 中成功加载 vtt。
我已在服务器端为来自任何域的请求启用 CORS。
有些文章说在`元素中添加crossorigin或crossorigin="anonymous"可以完成这项工作,但它不起作用。视频根本没有加载或出现不同的错误
我把我的代码放在下面
<body>
<div class="container">
<video id="myvideo" controls preload="auto" width="640" height="264" autoplay>
<source src=http://video.dublearn.net/-KqIgE-3roMSBbiHUmLI/video.mp4 type="video/mp4"></source>
<track kind="captions" label="English" srclang="en" src=http://video.dublearn.net/-KqIgE-3roMSBbiHUmLI/video.vtt default>
</video>
</body>
【问题讨论】:
标签: html5-video webvtt vtt