Loading Video JS dynamically from URL

梦想的初衷 提交于 2019-12-08 10:24:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!