admin管理员组文章数量:1356941
Why this throws up this error:
The element or ID supplied is not valid. (VideoJS)
I know it may be obvious but there's the code:
<script type="text/javascript">
var videoPlayer = _V_("example_video_1", {}, function(){
this.addEvent("ended", function(){
alert('Here I am');
});
});
</script>
and video ID set via PHP
<?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='{}'>";
?>
Why this throws up this error:
The element or ID supplied is not valid. (VideoJS)
I know it may be obvious but there's the code:
<script type="text/javascript">
var videoPlayer = _V_("example_video_1", {}, function(){
this.addEvent("ended", function(){
alert('Here I am');
});
});
</script>
and video ID set via PHP
<?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='{}'>";
?>
Share
Improve this question
edited Jan 19, 2013 at 12:26
ЯegDwight
25.3k10 gold badges47 silver badges52 bronze badges
asked Jan 18, 2013 at 12:01
user1990139user1990139
191 gold badge1 silver badge4 bronze badges
6
- is this the library used? github./zencoder/video-js – Janus Troelsen Commented Jan 18, 2013 at 12:03
- Please show the generated HTML, not the PHP code. – JJJ Commented Jan 18, 2013 at 12:04
- No - good point!generated - video id="example_video_1" class="video-js vjs-default-skin" controls width="240" height="320" autoplay preload="auto" data-setup='{}'> – user1990139 Commented Jan 18, 2013 at 12:46
- No - I only have <link href="video-js.css" rel="stylesheet"/> <script src="video.js"></script>. PLEASE can you give me correct versions. – user1990139 Commented Jan 18, 2013 at 13:01
- It's impossible to help if we don't know what library you're using. "video.js" couldn't be anything. – JJJ Commented Jan 19, 2013 at 11:31
1 Answer
Reset to default 5Make sure your script is after the video element it references. Otherwise your get "the element or ID supplied is not valid" because it doesn't exist at the point the script executes.
e.g.
<!DOCTYPE html>
<html>
<head>
<link href="http://vjs.zencdn/c/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn/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./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>
本文标签: javascriptvideojs ended eventStack Overflow
版权声明:本文标题:javascript - video.js ended event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744043673a2581130.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论