{"id":5447376,"date":"2014-11-04T00:11:07","date_gmt":"2014-11-04T00:11:07","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/script-not-working-3\/"},"modified":"2016-08-22T04:05:30","modified_gmt":"2016-08-22T04:05:30","slug":"script-not-working-3","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/script-not-working-3\/","title":{"rendered":"Script Not Working"},"content":{"rendered":"<p>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.<\/p>\n<p>You can check out my problem page by going to https:\/\/socialsipn.com\/test-page\/<\/p>\n<p>In the WordPress page, I have the following code:<\/p>\n<pre><code>&lt;div class=&quot;intro-video&quot;&gt;\n     [videojs controls=&quot;false&quot; preload=&quot;auto&quot; id=&quot;sipnvideo&quot; youtube=&quot;https:\/\/youtu.be\/5lQqBG8B2DQ&quot;][\/videojs]\n     &lt;script type=&quot;text\/javascript&quot;&gt;\n          &lt;!--\/\/--&gt;&lt;![CDATA[\/\/&gt;&lt;!--\n               $(document).ready(function() {\n                    RunMainScreenVideo();\n               });\n          \/\/--&gt;&lt;!]]&gt;\n     &lt;\/script&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<p>The RunMainScreenVideo script is below &#8211; it gets to the var myPlayer = videojs(&#8230; line but never gets any further. The script is registered properly &#8211; the commented out alerts worked &#8211; but I cannot get the video player to initialize.  Instead I keep getting &#8220;videojs undefined&#8221; exceptions.<\/p>\n<p>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.<\/p>\n<p>What am I doing wrong?<\/p>\n<p>Thanks!<\/p>\n<p>Ken<\/p>\n<pre><code>function RunMainScreenVideo() {\n     var isMobile = false;\n\n    if (screen.width &lt; 699) {\n        isMobile = true;\n    }\n\n    \/\/if (isMobile) {\n    \/\/    alert(&quot;Is still reading Mobile!!!&quot;);\n    \/\/}\n    \/\/else {\n    \/\/    alert(&quot;is NOT mobile!!!&quot;);\n    \/\/}\n\n    var myPlayer = videojs(&quot;sipnvideo&quot;);  \/\/Stops here\n    alert(&quot;Loaded player&quot;);\n\n    \/\/Load the correct video\n    if (isMobile) {\n        alert(&quot;is mobile&quot;);\n        myPlayer.src({ type: &quot;video\/youtube&quot;, src: &quot;https:\/\/youtu.be\/1LVyLVLqdA4&quot; });\n    }\n    else {\n        alert(&quot;is NOT mobile&quot;);\n        myPlayer.src({ type: &quot;video\/youtube&quot;, src: &quot;https:\/\/youtu.be\/feuItfTRqTs&quot; });\n    }\n\n    \/\/Start playing the video.\n    myPlayer.play();\n\n    \/\/Hangout until the video ends\n    while (!myPlayer.ended()) { }\n\n    \/\/Redirect to the main home page\n    window.location = &quot;https:\/\/socialsipn.com\/secure-online-communications\/&quot;;\n}<\/code><\/pre>\n<p>https:\/\/wordpress.org\/plugins\/videojs-html5-video-player-for-wordpress\/<\/p>\n","protected":false},"template":"","class_list":["post-5447376","topic","type-topic","status-closed","hentry","topic-tag-scripting","topic-tag-videojs"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5447376","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5447376\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=5447376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}