我正在使用videoJs来播放视频。
HTML
<video id="player-vjs_html5_api" class="vjs-tech" crossorigin="anonymous" preload="auto" src="http://path-to-video/small.mp4">
<p class="vjs-no-vjs">Your browser does not support video.</p>
</video>
的Javascript
loadMedia: function(path) {
player.src(path);
return void 0;
}
当我使用.webm
但我尝试使用mp4
时出现以下错误
VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) The media could not be loaded, either because the server or network failed or because the format is not supported.
我也试过了,但它没有工作
<video id="player-vjs_html5_api" class="vjs-tech" crossorigin="anonymous" preload="auto">
<source src="" type="video/mp4" />
<source src="" type="video/webm" />
<source src="" type="video/ogv" />
<p class="vjs-no-vjs">Your browser does not support video.</p>
</video>
和
loadMedia: function(path) {
player.src([
{ type: "video/mp4", src: path+".mp4" },
{ type: "video/webm", src: path+".webm" },
{ type: "video/ogg", src: path+".ogv" }
]);
return void 0;
}
但它也没有用。
答案 0 :(得分:0)
当我做了以下更改时,它有效。刚删除crossorigin="anonymous"
<video id="player-vjs_html5_api" class="vjs-tech" preload="auto">
<source src="" type="video/mp4" />
<source src="" type="video/webm" />
<source src="" type="video/ogv" />
<p class="vjs-no-vjs">Your browser does not support video.</p>
</video>
的javascript
loadMedia: function(path) {
player.src([
{ type: "video/mp4", src: path+".mp4" },
{ type: "video/webm", src: path+".webm" },
{ type: "video/ogg", src: path+".ogv" }
]);
return void 0;
}