【问题标题】:video player - video.js - (Wait Until the Player is Ready) not working视频播放器 - video.js - (等到播放器准备好)不工作
【发布时间】:2019-01-30 19:12:35
【问题描述】:

在使用 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>

【问题讨论】:

    标签: javascript video.js


    【解决方案1】:

    当头部中的脚本标签执行时,视频元素还不存在。您可以将脚本移动到正文的末尾。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-13
      • 1970-01-01
      • 2013-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多