我的需要
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,以便 vtt 可以成功加载到 html5 中。
我已经在服务器端为来自任何域的请求启用了 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>