javascriptwistia

Video API not executing onReady as expected


In the documentation for the wistia JS API, it simply says to call it under the iFrame with the attributed ID and the _all flag if you want to hit all videos on the page.

I'm trying to get a basic console log logged with the video API per the docs. The console log doesn't work and the documentation is very poor at explaining why.

I'm following the docs here:

https://wistia.com/support/developers/player-api

This is my code below:

<iframe title="Demo4 Video" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" src="https://fast.wistia.net/embed/iframe/zz038smet7?dnt=1#?secret=L8pVNj0787" data-secret="L8pVNj0787" frameborder="0" scrolling="no" width="640" height="360"></iframe>
            <script src="//fast.wistia.net/assets/external/E-v1.js"></script>
            <script>
            window._wq = window._wq || [];
                _wq.push({ id: "_all", onReady: function(video) {
                console.log("I got a handle to the video!", video);
            }});
          </script>

It says directly in the docs:

The exact same syntax will work with iframe embeds too:

My iFrame reference match, I'm loading the library fast.wistia.net/assets/external/E-v1.js and I'm using the _all flag to grab all videos. But I don't see the console log output.

What am I doing wrong?


Solution

  • The wistia api requires a class of wistia_embed on the iFrame to work:

    <iframe title="Demo4 Video" class="wp-embedded-content wistia_embed" sandbox="allow-scripts" security="restricted" src="https://fast.wistia.net/embed/iframe/zz038smet7?dnt=1#?secret=L8pVNj0787" data-secret="L8pVNj0787" frameborder="0" scrolling="no" width="640" height="360"></iframe>
            <script src="//fast.wistia.net/assets/external/E-v1.js"></script>
            <script>
            window._wq = window._wq || [];
                _wq.push({ id: "_all", onReady: function(video) {
                console.log("I got a handle to the video!", video);
            }});
          </script>