我在使用videos-panorama时遇到这个错误
Dom异常:对‘WebGLRenderingContext’执行'texImage2D‘失败:视频元素包含跨域数据,可能无法加载。
https://github.com/yanwsh/videojs-panorama
<code> `(function (window, videojs) { var player = window.player = videojs('videojs-panorama-player', {}, function () { }); var videoElement = document.getElementById("videojs-panorama-player"); var width = videoElement.offsetWidth; var height = videoElement.offsetHeight; player.width(width), player.height(height); player.panorama({ clickAndDrag: true, backToVerticalCenter: false, backToHorizonCenter: false, clickToToggle: true, maxLat: -10, initLat: -10, initLon: -270, rotateX: -Math.PI, NoticeMessage: (isMobile()) ? "please drag and drop the video" : "please use your mouse drag and drop the video", videoType: "fisheye", callback: function () { player.play(); } }); }(window, window.videojs));`
发布于 2019-11-06 09:09:26
这里解释了"CORS“的概念:https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
在Stack-Overflow上有一个较早的线程在这里讨论这个问题:enable cors in .htaccess
简而言之,大多数are服务器都很高兴,只要您为它们提供一个名为".htaccess“的两行文件,其中包含以下两行:
标题添加访问-控制-允许-来源"*“
Header添加Access-Control-Allow-Methods:"GET,POST,OPTIONS,DELETE,PUT“
https://stackoverflow.com/questions/58691058
复制相似问题