Video.JS not displaying until refresh



  • I have a custom route. domain.com/tv, which pulls an RTMP stream using video.js. However, the video never loads until I refresh the page. I believe it's because NodeBB loads the video tag dynamically, as detailed here.

    Their recommendation is to instantiate the video player 1) after the custom JS is loaded and 2) after the video tag is loaded. But I'm unsure of a way to run javascript in NodeBB after the page has fired. Any ideas?

    videojs("example_video_1", {}, function(){
      // Player (this) is initialized and ready.
    });
    


  • Wrap it in something like

    $(window).on('action:widgets.loaded', function() {
    //Your Code Here
    });
    

    Or

    $('document').ready(function() {
    //Your Code Here
    });
    

    Either will work, probably.



  • Currently testing with

    <link href="//vjs.zencdn.net/4.12/video-js.css" rel="stylesheet">
    <script src="//vjs.zencdn.net/4.12/video.js"></script>
    <script type="text/javascript">
    $('document').ready(function() {
        document.createElement('video');document.createElement('audio');document.createElement('track');
    });
    </script>
    

Log in to reply
 

Suggested Topics

  • 3
  • 3
  • 3
  • 6
  • 10
| |