Vhs object is null in videojs

Viewed 548

I am new to java script. I am trying to do a project on videojs. I am not able to get the vhs object in the below code. What wrong I am doing?

</head>
<body>
  <h1>This is a demo video</h1>

  <video-js id="demo_video" class="vjs-default-skin" controls preload="auto" width="640" height="268">
    <source src="http://127.0.0.1:8887/video/filename.m3u8" type="application/x-mpegURL">
  </video-js>


  
  <script src="https://unpkg.com/video.js/dist/video.js"></script>
  <script src="https://unpkg.com/@videojs/http-streaming/dist/videojs-http-streaming.js"></script>
  <script>
    var player = videojs("demo_video");
    var vhs = player.tech().vhs;
  </script>
</body>
</html>

The below code return as Uncaught TypeError: Cannot read property 'vhs' of undefined

var vhs = player.tech().vhs;
2 Answers

I have 2 suggestions, second one is I think the issue is.

  1. Make sure you have the proper version of the libraries.
  2. vhs is the runtime property which is attached to the tech object, you can only use it when HLS is in use. So make sure the HLS streaming protocol is in use when you call that.
Related