为什么会抛出此错误:
提供的元素或ID无效。(VideoJS)
我知道这可能很明显,但代码是这样的:
<script type="text/javascript">
var videoPlayer = _V_("example_video_1", {}, function(){
this.addEvent("ended", function(){
alert('Here I am');
});
});
</script>和通过PHP设置的视频ID
<?PHP
echo "<video id=\"example_video_1\" class=\"video-js vjs-default-skin\" controls width=\"".$vid_h."\" height=\"".$vid_w."\" autoplay preload=\"auto\" data-setup='{}'>";
?>发布于 2013-01-19 14:10:59
确保您的脚本在它引用的视频元素之后。否则,get“提供的元素或ID无效”,因为它在脚本执行时不存在。
例如:
<!DOCTYPE html>
<html>
<head>
<link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/c/video.js"></script>
</head>
<body>
<video id="example_video_1" class="video-js vjs-default-skin" controls preload="auto" width="360" height="202" autoplay data-setup="{}">
<source src="http://example.com/video.mp4" type='video/mp4'>
</video>
<script type="text/javascript">
var videoPlayer = _V_("example_video_1", {}, function(){
this.addEvent("ended", function(){
alert('Here I am');
});
});
</script>
</body>
</html>https://stackoverflow.com/questions/14398537
复制相似问题