Video.js with empty source

2019-05-04 18:12发布

问题:

Is there anyway I can place video.js without setting source on video tag? Video.js fails without source when starts.

I want place video.js without source and set sourace from js api later.

same question here but no one answered. VideoJS, without source?

回答1:

Use preload="none" on the video element

<video id="my_video" controls preload="none" class="video-js vjs-default-skin" data-setup="{}" />

Then load with the API

videojs("my_video").src([
  { type: "video/mp4", src: "http://vjs.zencdn.net/v/oceans.mp4" },
  { type: "video/webm", src: "http://vjs.zencdn.net/v/oceans.webm" }
]);


标签: video.js