gpt4 book ai didi

html - 从跨域加载 vtt 的问题

转载 作者:行者123 更新时间:2023-11-28 00:37:02 27 4
gpt4 key购买 nike

我在从跨域加载 vtt 时遇到问题:“加载 URL 域的不安全尝试...协议(protocol)和端口必须匹配。”我尝试将 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>

最佳答案

videocrossorigin 属性需要anonymoususe-credentials

<video controls autoplay crossorigin="use-credentials">
<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>

Mozilla's explanation

crossorigin

This enumerated attribute indicates whether to use CORS to fetch the related image. CORS-enabled resourcescan be reused in the element without being tainted. The allowed values are:

anonymous

Sends a cross-origin request without a credential. In other words, it sends the Origin: HTTP header without a cookie, X.509 certificate, or performing HTTP Basic authentication. If the server does not give credentials to the origin site (by not setting the Access-Control-Allow-Origin: HTTP header), the image will be tainted, and its usage restricted.

use-credentials

Sends a cross-origin request with a credential. In other words, it sends the Origin: HTTP header with a cookie, a certificate, or performing HTTP Basic authentication. If the server does not give credentials to the origin site (through Access-Control-Allow-Credentials: HTTP header), the image will be tainted and its usage restricted.

When not present, the resource is fetched without a CORS request (i.e. without sending the Origin: HTTP header), preventing its non-tainted used in elements. If invalid, it is handled as if the enumerated keyword anonymous was used. See CORS settings attributes for additional information.

关于html - 从跨域加载 vtt 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55645393/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com