javascript - video.js ended event - Stack Overflow

Why this throws up this error:The element or ID supplied is not valid. (VideoJS)I know it may be obviou

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
 |  Show 1 more ment

1 Answer 1

Reset to default 5

Make 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>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744043674a4548780.html

相关推荐

  • javascript - video.js ended event - Stack Overflow

    Why this throws up this error:The element or ID supplied is not valid. (VideoJS)I know it may be obviou

    9天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信