“crossOrigin”设置为“anonymous”的视频无法加载

时间:2015-10-09 16:52:01

标签: javascript html html5 html5-video cors

我正在尝试加载crossOrigin属性设置为anonymous的视频,但每当我这样做时视频无法加载。

Chrome只输出传递给错误事件监听器的错误对象Firefox说这是由于缺少CORS标头,IE似乎加载了视频,但我不确定原因。



var video = document.createElement("video");
video.id = "video_1";
video.width = 500;
video.height = 300;
video.src = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
video.loop = "true";
video.muted = "true";
video.autoPlay = "true";
video.crossOrigin = "anonymous";

var videoWrapper = document.getElementById("video-wrapper");

video.addEventListener('loadeddata', function() {
  console.log("successful load");
  videoWrapper.appendChild(video);
}, false);

video.addEventListener('error', function(error) {
  console.log("error loading");
  console.log(error);
});

video.load();

<div id="video-wrapper"></div>
&#13;
&#13;
&#13;

JSFiddle Demo

0 个答案:

没有答案