问题
I am getting this error when using videos-panorama
Dom Exception: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The video element contains cross-origin data, and may not be loaded.
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));
回答1:
The concept of "CORS" is explained here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
There is an earlier thread here on Stack-Overflow discussing this here: enable cors in .htaccess
To boil it all down, most webservers are happy, if you just supply them with a two-line file named ".htaccess", containing these 2 lines:
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
来源:https://stackoverflow.com/questions/58691058/ionic-3-videojs-panorama-not-supporting-in-android-getting-error-domexception