从URL动态加载视频JS

时间:2017-06-30 06:41:35

标签: javascript jquery video html5-video video.js

我想从网址动态加载视频js,但它无效。

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/(动态添加网址 - 不起作用)

JSFIDDLE:http://jsfiddle.net/hiteshbhilai2010/0a5u3ew4/334/(在HTML中添加的URL - Works)

answer对我不起作用。有人可以提供帮助。谢谢!!!

1 个答案:

答案 0 :(得分:0)

source: [{
            type : 'video/mp4',
            src : 'http://vjs.zencdn.net/v/oceans.mp4'
        }]

来源应为来源

更多选项可见here