• I had originally posted this directly on GitHub (https://github.com/videojs/video.js/issues/1635#event-187631860) and just now realized I should have posted here.

    You can check out my problem page by going to https://socialsipn.com/test-page/

    In the WordPress page, I have the following code:

    <div class="intro-video">
         [videojs controls="false" preload="auto" id="sipnvideo" youtube="https://youtu.be/5lQqBG8B2DQ"][/videojs]
         <script type="text/javascript">
              <!--//--><![CDATA[//><!--
                   $(document).ready(function() {
                        RunMainScreenVideo();
                   });
              //--><!]]>
         </script>
    </div>

    The RunMainScreenVideo script is below – it gets to the var myPlayer = videojs(… line but never gets any further. The script is registered properly – the commented out alerts worked – but I cannot get the video player to initialize. Instead I keep getting “videojs undefined” exceptions.

    I attempted to add the CDN CSS and JS links in my Header.php file but that did not help. I have also taken out and added the video link back in but that does not make any difference.

    What am I doing wrong?

    Thanks!

    Ken

    function RunMainScreenVideo() {
         var isMobile = false;
    
        if (screen.width < 699) {
            isMobile = true;
        }
    
        //if (isMobile) {
        //    alert("Is still reading Mobile!!!");
        //}
        //else {
        //    alert("is NOT mobile!!!");
        //}
    
        var myPlayer = videojs("sipnvideo");  //Stops here
        alert("Loaded player");
    
        //Load the correct video
        if (isMobile) {
            alert("is mobile");
            myPlayer.src({ type: "video/youtube", src: "https://youtu.be/1LVyLVLqdA4" });
        }
        else {
            alert("is NOT mobile");
            myPlayer.src({ type: "video/youtube", src: "https://youtu.be/feuItfTRqTs" });
        }
    
        //Start playing the video.
        myPlayer.play();
    
        //Hangout until the video ends
        while (!myPlayer.ended()) { }
    
        //Redirect to the main home page
        window.location = "https://socialsipn.com/secure-online-communications/";
    }

    https://wordpress.org/plugins/videojs-html5-video-player-for-wordpress/

The topic ‘Script Not Working’ is closed to new replies.