从跨域加载vtt的问题

问题描述 投票:1回答:1

我有从跨域加载vtt的问题:“不安全的尝试加载URL域...协议和端口必须匹配。”我试图在视频中添加crossorigin =“true”,它在chrome和firefox中工作,但它在Internet Explorer 11中不起作用。还有其他方法可以在IE11中从跨域获取vtt文件吗?

<video controls autoplay crossorigin="true">
     <source src="http://ronallo.com/demos/webvtt-cue-settings/soybean-talk-clip.mp4" type="video/mp4">
     <track label="Captions" kind="captions" srclang="en" src="http://ronallo.com/demos/webvtt-cue-settings/soybean-talk-clip.vtt" id="caption-change-track" default="">
  </video>
html5 video html5-video cross-domain webvtt
1个回答
0
投票

通过在请求vtt文件时在响应中包含以下标头,您需要在原始服务器上设置跨域策略:

Access-Control-Allow-Origin: *

如果需要,您还可以将允许的域限制为特定条目。

尽管正确设置了crossorigin属性(请参阅https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes),但从客户端来看,你不能强制超越 - 在这种情况下,anonymous确实有助于浏览器正确协商请求

© www.soinside.com 2019 - 2024. All rights reserved.