问题
I want to load video js dynamically from URL but it is not working.
var container = document.getElementById("my_video_1");
videojs(container, {
controls: true,
class:'video-js vjs-default-skin',
techOrder: ["html5", "flash"],
source: [{
type : 'video/mp4',
src : 'http://vjs.zencdn.net/v/oceans.mp4'
}]
}, function() {
});
<script src="https://raw.githubusercontent.com/CharlotteDunois/videojs-loopbutton/master/videojs.loopbutton.min.js"></script>
<link href="https://raw.githubusercontent.com/CharlotteDunois/videojs-loopbutton/master/videojs.loopbutton.css" rel="stylesheet"/>
<link href="http://vjs.zencdn.net/4.11/video-js.css" rel="stylesheet"/>
<script src="http://vjs.zencdn.net/4.11/video.js"></script>
<video id="my_video_1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="268"
data-setup='{ "playbackRates": [0.5, 1, 1.5, 2],"loopbutton": true }'
>
</video>
JSFIDDLE : http://jsfiddle.net/hiteshbhilai2010/0a5u3ew4/332/ (Dynamically URL added - does not work)
JSFIDDLE : http://jsfiddle.net/hiteshbhilai2010/0a5u3ew4/334/ (URL added in the html - Works)
This answer is not working for me. Can some one help. thanks!!!
回答1:
source: [{
type : 'video/mp4',
src : 'http://vjs.zencdn.net/v/oceans.mp4'
}]
source should be sources
more options could be see here
来源:https://stackoverflow.com/questions/44840150/loading-video-js-dynamically-from-url