jwplayer

jw8-player-errors-reference 332001 and Uncaught ReferenceError: jwplayer is not defined


I am using jwplayer (version - 8.26).

I am getting the following errors in the console:

  1. jw8-player-errors-reference 332001

  2. Uncaught ReferenceError: jwplayer is not defined

Following is the error description from console

VM2378:2 Uncaught ReferenceError: jwplayer is not defined
at eval (eval at <anonymous> (main.js?v=7db5d0f849a2cbf25bae06b650e7cb17:1:14737), <anonymous>:2:8)
at eval (<anonymous>)
at main.js?v=7db5d0f849a2cbf25bae06b650e7cb17:1:14737
at Function.globalEval (main.js?v=7db5d0f849a2cbf25bae06b650e7cb17:1:14748)
at ea.fn.init.domManip (main.js?v=7db5d0f849a2cbf25bae06b650e7cb17:1:63440)
at ea.fn.init.append (main.js?v=7db5d0f849a2cbf25bae06b650e7cb17:1:60940)
at ea.fn.init.<anonymous> (main.js?v=7db5d0f849a2cbf25bae06b650e7cb17:1

I am using the code snippet as shown below. The error is happening when jwplayer is referenced at line "jwplayer.key" in the code below

    <script type="text/javascript"
src="//content.jwplatform.com/libraries/XXXX.js"></script>

<script type="text/javascript">
jwplayer.key = "GO/bHvcIycFaixHqFyFeXsWuMA5+Yr1Dm+PmH6I3sZ0=";
</script>

<div class="on-air-items-container oai-show-live-video">
<div class="video-wrapper">
<div id="vid-1"></div>

<script type="text/javascript">
var playerInstance = jwplayer("vid-1");
playerInstance
.setup({
androidhls : true,
playlist: '//cdn.jwplayer.com/v2/media/xxxxx',
autostart : false,
width : "100%",
aspectratio : "16:9"
});
</script>

Questions:

  1. What is the reason for "jwplayer is not defined" error? I am getting this error even though I am loading jwplayer using

"script type="text/javascript" src="//content.jwplatform.com/libraries/XXXX.js"

  1. Is the error happening because the jwplayer is referenced just immediately after the jwplayer js is loaded?

Solution

  • In the jwplayer documentation it is said that for a cloud hosted jwplayer there is no need to redeclare jwplayer.key value in the code.

    https://docs.jwplayer.com/players/docs/jw8-add-a-player-library#cloud-hosted-by-jwp-with-api-calls

    Since cloud hosted jwplayer was used by my website, I removed the following line as the jwplayer key was already set and i don't need to repeat the setting of the key again in the code.

    <script type="text/javascript">
    jwplayer.key = "GO/bHvcIycFaixHqFyFeXsWuMA5+Yr1Dm+PmH6I3sZ0=";
    </script>
    

    This resolved my issue