使用video.js(videojs.com)时遇到了一些麻烦
这个简单的html是从以下示例中提取的: https://github.com/videojs/video.js/releases/download/v7.5.0/video-js-7.5.0.zip
首先,我只希望“等待播放器准备就绪”工作并弹出“嗨”。 (https://docs.videojs.com/docs/guides/api.html)
https://jsfiddle.net/a7pn0j28/
<!DOCTYPE html>
<html lang="en">
<head>
<title>Video.js | HTML5 Video Player</title>
<link href="https://vjs.zencdn.net/7.0/video-js.min.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/7.0/video.min.js"></script>
<script>
videojs("example_video_1").ready(function(){
alert('hi')
//var myPlayer = this;
// EXAMPLE: Start playing the video.
//myPlayer.play();
});
</script>
</head>
<body>
<video id="example_video_1" class="video-js" controls preload="none" width="640" height="264" poster="http://vjs.zencdn.net/v/oceans.png" data-setup="{}">
<source src="http://vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
<source src="http://vjs.zencdn.net/v/oceans.webm" type="video/webm">
</video>
</body>
</html>
答案 0 :(得分:0)
执行头部的script标签时,视频元素尚不存在。您可以将脚本移到正文的末尾。